Class: Attrio::DefaultValue::Symbol

Inherits:
Base show all
Defined in:
lib/attrio/default_value/symbol.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/symbol.rb', line 8

def self.handle?(value)
  value.is_a?(::Symbol)
end

Instance Method Details

#call(instance) ⇒ Object

Evaluates the value via self.object#send(value) Symbol value is returned if the object doesn’t respond to value

Parameters:



17
18
19
# File 'lib/attrio/default_value/symbol.rb', line 17

def call(instance)
  instance.respond_to?(self.value, true) ? instance.send(self.value) : self.value
end