apotonick/representable — pull request #55 by rsutphin (2013-08-06 19:22:28+00:00)
Title: Ensure enclosing decorator properties don't show up in inline decorators

In 1.6.0 and master, attempts to use inline decorators where the enclosing decorator has other properties will fail with an exception like the below. The immediate problem is that the inline decorator is attempting to bind properties from the enclosing decorator. (See the test in the patch for a concrete example.)

The problem is that the inline decorator is made to descend from the enclosing decorator due to a possible-surprising behavior of `self` in class methods in ruby. The patch fixes the problem by using the enclosing decorator's superclass as the superclass for the inline decorator.

```
NoMethodError: undefined method `title' for #
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:77:in `block in get'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:93:in `represented_exec_for'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:76:in `get'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:36:in `block in compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:93:in `represented_exec_for'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:35:in `compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:67:in `compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:35:in `serialize_property'
/Users/rsutphin/ruby/representable/lib/representable/feature/readable_writeable.rb:11:in `serialize_property'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:25:in `block in serialize'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:24:in `each'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:24:in `serialize'
/Users/rsutphin/ruby/representable/lib/representable.rb:29:in `create_representation_with'
/Users/rsutphin/ruby/representable/lib/representable/hash.rb:38:in `to_hash'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:139:in `serialize'
/Users/rsutphin/ruby/representable/lib/representable/bindings/hash_bindings.rb:42:in `serialize_for'
/Users/rsutphin/ruby/representable/lib/representable/bindings/hash_bindings.rb:38:in `write'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:57:in `write_fragment_for'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:52:in `write_fragment'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:36:in `block in compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:93:in `represented_exec_for'
/Users/rsutphin/ruby/representable/lib/representable/binding.rb:35:in `compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:67:in `compile_fragment'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:35:in `serialize_property'
/Users/rsutphin/ruby/representable/lib/representable/feature/readable_writeable.rb:11:in `serialize_property'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:25:in `block in serialize'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:24:in `each'
/Users/rsutphin/ruby/representable/lib/representable/mapper.rb:24:in `serialize'
/Users/rsutphin/ruby/representable/lib/representable.rb:29:in `create_representation_with'
/Users/rsutphin/ruby/representable/lib/representable/hash.rb:38:in `to_hash'
```