Class: Attrio::DefaultValue::Callable

Inherits:
Base show all
Defined in:
lib/attrio/default_value/callable.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

handle, #initialize

Constructor Details

This class inherits a constructor from Attrio::DefaultValue::Base

Class Method Details

.handle?(value) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/attrio/default_value/callable.rb', line 8

def self.handle?(value)
  value.respond_to?(:call)
end

Instance Method Details

#call(instance) ⇒ Object

Evaluates the value via value#call

Parameters:

Returns:

  • (Object)

    evaluated value



18
19
20
# File 'lib/attrio/default_value/callable.rb', line 18

def call(instance)
  self.value.call(instance, self.attribute)
end