Class: Virtus::Attribute::DefaultValue Private

Inherits:
Object
  • Object
show all
Extended by:
DescendantsTracker
Defined in:
lib/virtus/attribute/default_value.rb,
lib/virtus/attribute/default_value/from_symbol.rb,
lib/virtus/attribute/default_value/from_callable.rb,
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.

Class representing the default value option

Direct Known Subclasses

FromCallable, FromClonable, FromSymbol

Defined Under Namespace

Classes: FromCallable, FromClonable, FromSymbol

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ undefined

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.

Initializes an default value instance

Parameters:

  • value (Object)


36
37
38
# File 'lib/virtus/attribute/default_value.rb', line 36

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

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.

Returns the value instance

Returns:

  • (Object)


27
28
29
# File 'lib/virtus/attribute/default_value.rb', line 27

def value
  @value
end

Class Method Details

.build(*args) ⇒ Virtus::Attribute::DefaultValue

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.

Builds a default value instance



17
18
19
20
# File 'lib/virtus/attribute/default_value.rb', line 17

def self.build(*args)
  klass = descendants.detect { |descendant| descendant.handle?(*args) } || self
  klass.new(*args)
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

Returns:

  • (Object)

    evaluated value



45
46
47
# File 'lib/virtus/attribute/default_value.rb', line 45

def call(*)
  value
end