lib/rest_in_peace.rb in rest-in-peace-5.1.0 vs lib/rest_in_peace.rb in rest-in-peace-6.0.0

- old
+ new

@@ -23,12 +23,13 @@ changed.each do |key| value = send(key) hash_representation[key.to_sym] = hash_representation_of_object(value) end else - hash_representation = to_h + hash_representation.merge! to_h.keep_if { |key| write_attribute?(key) } end + if self.class.rip_namespace { id: id, self.class.rip_namespace => hash_representation } else hash_representation end @@ -79,9 +80,13 @@ def hash_representation_of_object(object) return object.payload if object.respond_to?(:payload) return object.map { |element| hash_representation_of_object(element) } if object.is_a?(Array) object + end + + def write_attribute?(attribute) + self.class.rip_attributes[:write].include?(attribute.to_sym) end module ClassMethods attr_accessor :api attr_accessor :rip_namespace