Class: Deserializer::Base
- Inherits:
-
Object
- Object
- Deserializer::Base
- Includes:
- Attributable
- Defined in:
- lib/deserializer/base.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
-
.from_params(params = {}) ⇒ Object
deserializer usage functions.
- .permitted_params ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
22 23 24 |
# File 'lib/deserializer/base.rb', line 22 def object @object end |
Class Method Details
.from_params(params = {}) ⇒ Object
deserializer usage functions
13 14 15 |
# File 'lib/deserializer/base.rb', line 13 def from_params( params = {} ) new( params ).deserialize end |
.permitted_params ⇒ Object
17 18 19 |
# File 'lib/deserializer/base.rb', line 17 def permitted_params __attrs.keys end |
Instance Method Details
#deserialize ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/deserializer/base.rb', line 24 def deserialize object ||= {} # deserialize self.class.__attrs.each do |_, attr| object.merge!( attr.to_hash( params, self ) ) do |key, old_value, new_value| # in the case that 2 has_ones merge into the same key. Not sure i want to support this if old_value.is_a?( Hash ) && new_value.is_a?( Hash ) old_value.merge new_value else new_value end end end object end |