Class: FieldMapper::Standard::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/field_mapper/standard/value.rb

Direct Known Subclasses

Custom::Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, field: nil) ⇒ Value

Returns a new instance of Value.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
# File 'lib/field_mapper/standard/value.rb', line 11

def initialize(
  value,
  field: nil
)
  raise ArgumentError.new("field is required") if
    field.nil?

  @field = field
  @value = field.cast(value, as_single_value: true)
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



6
7
8
# File 'lib/field_mapper/standard/value.rb', line 6

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/field_mapper/standard/value.rb', line 6

def value
  @value
end