Class: Virtus::Attribute::EmbeddedValue::FromOpenStruct

Inherits:
Coercer
  • Object
show all
Defined in:
lib/virtus/attribute/embedded_value.rb

Overview

Builds OpenStruct-like instance with attributes passed to the constructor as a hash

Instance Attribute Summary

Attributes inherited from Coercer

#primitive, #type

Instance Method Summary collapse

Methods inherited from Coercer

#initialize, #success?

Constructor Details

This class inherits a constructor from Virtus::Coercer

Instance Method Details

#call(input) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/virtus/attribute/embedded_value.rb', line 33

def call(input)
  if input.kind_of?(primitive)
    input
  elsif not input.nil?
    primitive.new(input)
  end
end