Class: Virtus::Attribute::EmbeddedValue::FromStruct

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

Overview

Builds Struct-like instance with attributes passed to the constructor as a list of args rather than 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



16
17
18
19
20
21
22
# File 'lib/virtus/attribute/embedded_value.rb', line 16

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