ar_http_wrapper 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,12 +12,12 @@ class ActiveRecordHttpWrapper
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.create(args={})
|
15
|
-
options = { :body => args
|
15
|
+
options = { :body => prepared_params(args) }
|
16
16
|
_parsed post(to_path(nil,"/"), options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.update_attributes(_syncable, args={})
|
20
|
-
options = { :body => args
|
20
|
+
options = { :body => prepared_params(args) }
|
21
21
|
_parsed put(to_path(_syncable.id, "/"), options)
|
22
22
|
end
|
23
23
|
|
@@ -52,6 +52,22 @@ class ActiveRecordHttpWrapper
|
|
52
52
|
|
53
53
|
private
|
54
54
|
|
55
|
+
def self.klass_to_param
|
56
|
+
self.to_s.underscore.split('/').last.to_sym
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.prepared_params(args={})
|
60
|
+
if !!args[:params]
|
61
|
+
args[:params]
|
62
|
+
else
|
63
|
+
if !!args[klass_to_param]
|
64
|
+
args
|
65
|
+
else
|
66
|
+
{klass_to_param => args}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
55
71
|
def self._parsed(to_parse)
|
56
72
|
if to_parse.is_a?(Array)
|
57
73
|
to_parse.map{|_j| OpenStruct.new _j}
|