Class: Strict::Attributes::Coercer
- Inherits:
-
Object
- Object
- Strict::Attributes::Coercer
- Defined in:
- lib/strict/attributes/coercer.rb
Instance Attribute Summary collapse
-
#attributes_class ⇒ Object
readonly
Returns the value of attribute attributes_class.
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(attributes_class) ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize(attributes_class) ⇒ Coercer
Returns a new instance of Coercer.
8 9 10 |
# File 'lib/strict/attributes/coercer.rb', line 8 def initialize(attributes_class) @attributes_class = attributes_class end |
Instance Attribute Details
#attributes_class ⇒ Object (readonly)
Returns the value of attribute attributes_class.
6 7 8 |
# File 'lib/strict/attributes/coercer.rb', line 6 def attributes_class @attributes_class end |
Instance Method Details
#call(value) ⇒ Object
12 13 14 15 16 |
# File 'lib/strict/attributes/coercer.rb', line 12 def call(value) return value if value.nil? || !value.respond_to?(:to_h) coerce(value.to_h) end |