Module: ResultClassComponents::Serialization
- Defined in:
- lib/kweerie/result_class_components/serialization.rb
Instance Method Summary collapse
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
16 17 18 19 |
# File 'lib/kweerie/result_class_components/serialization.rb', line 16 def deconstruct_keys(keys) symbolized = deep_symbolize_keys(to_h) keys ? symbolized.slice(*keys) : symbolized end |
#to_h ⇒ Object
5 6 7 8 9 10 |
# File 'lib/kweerie/result_class_components/serialization.rb', line 5 def to_h attribute_names.each_with_object({}) do |name, hash| value = instance_variable_get("@#{name}") hash[name.to_s] = serialize_value(value) end end |
#to_json(*args) ⇒ Object
12 13 14 |
# File 'lib/kweerie/result_class_components/serialization.rb', line 12 def to_json(*args) to_h.to_json(*args) end |