ar_http_wrapper 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,12 +12,12 @@ class ActiveRecordHttpWrapper
12
12
  end
13
13
 
14
14
  def self.create(args={})
15
- options = { :body => args[:params] }
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[:params] }
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}
@@ -1,3 +1,3 @@
1
1
  module ArHttpWrapper
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_http_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: