Ok, well if we think this is the best convention for introducing options
into hashes, we need to document this well. I think that we should remove
the _options and basically the source name should map to an attribute in
the hash completely. I think we can use this more generically that way for
other things that may need to specify some source attribute in the hash.


On Tue, Nov 12, 2013 at 8:04 AM, Chaim Solomon <notifications@github.com>wrote:

> In lib/crichton/representor/factory.rb:
>
> > @@ -83,6 +83,22 @@ def initialize(target, state = nil)
> >
> >              define_singleton_method(:state, lambda { state }) if state
> >            end
> > +
> > +          ##
> > +          # Use the *_options lambda from the collection if it is provided
> > +          def method_missing(method, *args, &block)
> > +            if method.to_s.ends_with?('_options') && @target.include?(method.to_s)
>
> Not sure about doc example. For the demo service, I put a lambda into
> drds_collection = {
> total_count: drds.count,
> items: drds,
> location_options: lambda {|h| {'list' => ['option1', 'option2a']} }
> }
> in drds.rb and the factory maps the method call to the lambda.
> I limited it to _options. Technically that isn't hard to unlimit, but I'm
> not sure if that is wanted.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/mdsol/crichton/pull/82/files#r7596299>
> .
>