Class: Attrio::DefaultValue::Clonable

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

Constant Summary collapse

SINGLETON_CLASSES =
[::NilClass, ::TrueClass, ::FalseClass, ::Numeric,  ::Symbol ].freeze

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)


10
11
12
13
14
15
16
17
# File 'lib/attrio/default_value/clonable.rb', line 10

def self.handle?(value)
  case value
  when *SINGLETON_CLASSES
    false
  else
    true
  end
end

Instance Method Details

#callObject

Evaluates the value via value#clone

Returns:

  • (Object)

    evaluated value



23
24
25
# File 'lib/attrio/default_value/clonable.rb', line 23

def call(*)
  @value.clone
end