Class: DefaultValueFor::BlockValueContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/default_value_for.rb

Instance Method Summary collapse

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