module NinjaModel::Marshalling::InstanceMethods
Public Instance Methods
marshal_dump()
click to toggle source
# File lib/ninja_model/marshalling.rb, line 6 def marshal_dump exceptions = %w(@association_cache @aggregation_cache @attributes) h = self.instance_variables.inject({}) { |r, k| unless exceptions.include?(k.to_s) r[k.to_s] = instance_variable_get(k) end r } h['@attributes'] = @attributes.inject({}) { |a, (k, v)| a[k] = read_attribute(k) a } ActiveSupport::JSON.encode(h) end
marshal_load(data)
click to toggle source
# File lib/ninja_model/marshalling.rb, line 21 def marshal_load(data) h = ActiveSupport::JSON.decode(data) h.each do |k, v| if k.eql?('@attributes') @attributes = {} v.each do |n, x| write_attribute(n, x) end else instance_variable_set(k, v) end end @association_cache = {} @aggregation_cache = {} end