Class: Virtus::Attribute::DefaultValue::FromClonable Private

Inherits:
Virtus::Attribute::DefaultValue show all
Defined in:
lib/virtus/attribute/default_value/from_clonable.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents default value evaluated via a clonable object

Constant Summary collapse

SINGLETON_CLASSES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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

Instance Attribute Summary

Attributes inherited from Virtus::Attribute::DefaultValue

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Virtus::Attribute::DefaultValue

build, #initialize

Methods included from DescendantsTracker

#add_descendant, #descendants

Constructor Details

This class inherits a constructor from Virtus::Attribute::DefaultValue

Class Method Details

.handle?(value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return if the class can handle the value

Parameters:

Returns:



19
20
21
22
23
24
25
26
# File 'lib/virtus/attribute/default_value/from_clonable.rb', line 19

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

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluates the value via value#clone

Returns:

  • (Object)

    evaluated value



33
34
35
# File 'lib/virtus/attribute/default_value/from_clonable.rb', line 33

def call(*)
  @value.clone
end