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)


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

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)


25
26
27
# File 'lib/virtus/attribute/default_value.rb', line 25

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



15
16
17
18
# File 'lib/virtus/attribute/default_value.rb', line 15

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



43
44
45
# File 'lib/virtus/attribute/default_value.rb', line 43

def call(*)
  value
end