Class: DefaultValueFor::BlockValueContainer
- Inherits:
-
Object
- Object
- DefaultValueFor::BlockValueContainer
- Defined in:
- lib/default_value_for.rb
Instance Method Summary collapse
- #evaluate(instance) ⇒ Object
-
#initialize(block) ⇒ BlockValueContainer
constructor
A new instance of BlockValueContainer.
Constructor Details
#initialize(block) ⇒ BlockValueContainer
Returns a new instance of BlockValueContainer.
37 38 39 |
# File 'lib/default_value_for.rb', line 37 def initialize(block) @block = block end |
Instance Method Details
#evaluate(instance) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/default_value_for.rb', line 41 def evaluate(instance) if @block.arity == 0 return @block.call else return @block.call(instance) end end |