class NestedStruct::Field
Attributes
coercer[R]
name[R]
Public Class Methods
new(name, coercer_expression = nil)
click to toggle source
# File lib/nested_struct/field.rb, line 5 def initialize(name, coercer_expression = nil) @name = name @coercer = Coercer.new(coercer_expression) if coercer_expression end
Public Instance Methods
coerced?()
click to toggle source
# File lib/nested_struct/field.rb, line 17 def coerced? !coercer.nil? end
with(value)
click to toggle source
# File lib/nested_struct/field.rb, line 10 def with(value) return value if value.nil? return value if value.is_a?(NestedStruct::Empty) return value if !coerced? coercer.coerce(value) end