Method: Representable::Binding#evaluate_option

Defined in:
lib/representable/binding.rb

#evaluate_option(name, *args) ⇒ Object

Evaluate the option (either nil, static, a block or an instance method call) or executes passed block when option not defined.



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/representable/binding.rb', line 118

def evaluate_option(name, *args)
  unless proc = @definition[name] # TODO: this could dispatch directly to the @definition using #send?
    return yield if block_given?
    return
  end

  # TODO: it would be better if user_options was nil per default and then we just don't pass it into lambdas.
  options = self[:pass_options] ? Options.new(self, user_options, represented, parent_decorator) : user_options

  proc.evaluate(exec_context, *(args<<options)) # from Uber::Options::Value.
end