Re: [friendly] method_missing idea
- James Golick
- 2009-12-25 @ 01:08
There are a couple of reasons I'm not doing this.
First of all, I'm not crazy about method_missing. It usually ends up being
more trouble to debug than its worth. One of Friendly's design goals is to
avoid method_missing as much as possible.
The second reason is type-casting. JSON only has a few native types. When
you want to store anything else in your JSON, you have to have some type
conversion in place somewhere. To accomplish that, your attributes need to
be associated with a type, so that Friendly knows how to convert them (see
On Thu, Dec 24, 2009 at 6:15 PM, Alan deLevie <email@example.com> wrote:
> This is my first message to the mailing list. Friendly looks damn
> I had a feature idea:
> Supposed I have the model:
> class Item
> include Friendly::Document
> attribute :name, String
> I save a record of Item like so:
> >> i = Item.new
> => #<Item:0x7fda11119c50>
> >> i.name = "hello"
> => "hello"
> >> i.foo = "bar"
> NoMethodError: undefined method `foo=' for #<Item:0x7fda11119c50
> from (irb):7
> Why not on method_missing, dynamically add the 'foo' attribute onto Item
> and save the record?