Class: ReactiveRecord::Operations::Base
- Inherits:
-
Hyperloop::ControllerOp
- Object
- Hyperloop::ControllerOp
- ReactiveRecord::Operations::Base
- Defined in:
- lib/reactive_record/active_record/reactive_record/operations.rb
Overview
to make debug easier we convert all the object_id strings to be hex representation
Constant Summary collapse
- FORMAT =
'0x%x'
Class Method Summary collapse
- .deserialize_params(hash) ⇒ Object
- .deserialize_response(response) ⇒ Object
- .serialize_params(hash) ⇒ Object
- .serialize_response(response) ⇒ Object
Class Method Details
.deserialize_params(hash) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/reactive_record/active_record/reactive_record/operations.rb', line 26 def self.deserialize_params(hash) hash['associations'].each do |assoc| assoc['parent_id'] = assoc['parent_id'].to_i(16) assoc['child_id'] = assoc['child_id'].to_i(16) end if hash['associations'] hash['models'].each do |assoc| assoc['id'] = assoc['id'].to_i(16) end if hash['models'] hash end |
.deserialize_response(response) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/reactive_record/active_record/reactive_record/operations.rb', line 44 def self.deserialize_response(response) response[:saved_models].each do |saved_model| saved_model[0] = saved_model[0].to_i(16) end if response.is_a?(Hash) && response[:saved_models] response end |
.serialize_params(hash) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/reactive_record/active_record/reactive_record/operations.rb', line 15 def self.serialize_params(hash) hash['associations'].each do |assoc| assoc['parent_id'] = FORMAT % assoc['parent_id'] assoc['child_id'] = FORMAT % assoc['child_id'] end if hash['associations'] hash['models'].each do |assoc| assoc['id'] = FORMAT % assoc[:id] end if hash['models'] hash end |
.serialize_response(response) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/reactive_record/active_record/reactive_record/operations.rb', line 37 def self.serialize_response(response) response[:saved_models].each do |saved_model| saved_model[0] = FORMAT % saved_model[0] end if response.is_a?(Hash) && response[:saved_models] response end |