lib/rest/api/client.rb in rest-api-client-0.1.8 vs lib/rest/api/client.rb in rest-api-client-0.1.9
- old
+ new
@@ -139,12 +139,28 @@
def ==(other)
id == other.id
end
+ protected
+
+ def to_hash_params
+ hash = {}
+ self.attributes.each do |key, value|
+ value_to_hash = value
+ if value_to_hash && value_to_hash.is_a?(RestModel)
+ hash["#{key}_id"] = value.id
+ value_to_hash = value.to_hash_params
+ end
+ hash[key] = value_to_hash
+ end
+ hash
+ end
+
private
+
def get_params
- {:type => self.class, :params => {get_model_name => self.attributes}}
+ {:type => self.class, :params => {get_model_name => self.to_hash_params}}
end
def update_attributes(response)
self.attributes = response && response.is_a?(self.class) ? response.attributes : {}
end