apiaryio/redsnow — pull request #48 by nogates (2014-12-15 00:08:45+00:00)
Title: Use singleton methods instead of instance variables / getters

Hello guys,

As you know, the ability to access the parent node using an instance variable was introduced as part of these PRs (https://github.com/apiaryio/redsnow/pull/45 / https://github.com/apiaryio/redsnow/pull/46), which I created myself.I would like to change this functionality and use a different approach to access the parent nodes.

The problem is that if we use instance variables, methods like `ActiveModel#to_json` will fail to inspect the objects properly, because the will get stuck into a circular loop where the action, for example, references the resource and the resource references the action over and over again, returning an error eventually

```ruby
parsed_blueprint = RedSnow.parse(raw_api)
parsed_blueprint.to_json # returns an error => SystemStackError: stack level too deep
```

In this PR, I have changed how the nodes reference their parent by using define_singleton_method. I think that this is a better approach that the old one. I haven't changed any test as you can see, so the general behaviour should be the same.

I am really sorry for the noise, and I am looking forward to hear your opinion about this.

Thanks.