smooth_operator 1.30.2 → 1.30.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmNmYjBjMThiMjVhZWM5ODE3OWI0YTI3Y2Q4MDM5YWNkNDBmMDJmZQ==
4
+ Mjk5MzhiZTA5NTU3ZTA1ZmU2NmYwM2Q2NDgzOGUwMGQyODU4MjFiNg==
5
5
  data.tar.gz: !binary |-
6
- MDMxZTQyNTZiNTYxZDQ2NzUyMWE4YmY4OGM1MjUxMGI4ZTRkMGU5YQ==
6
+ M2NjY2ZjNjE2MmM0ZTBmOTI5MzgyYzI1ZTk5NzQ0MDExNDVlMzEzNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTFmOWM1MzUyOWIzNDVlOTJmZDI2NzUzYTY5YmE3ZmM3MTg4NGM5MjJhZmVh
10
- NWE5NmZjZjVkMGFjNGM5ZGZjYzhjMjk3NGZmNGRmZWMxOGNlYjYxNDBlOTkx
11
- ZmFkODljZDE3NGI2MGJjYWJlZWFkOGFkZDBhMWE0M2U1YWE0NjQ=
9
+ MDIwNjdiM2EyM2JkNzc0MzQ1YmUxM2UwODAwY2Y5OGMxNmU0YTIwNTAxYjc4
10
+ NjcyMjhkNzI3MDdmOTA3ODg4NzQ2MmMzMDg4YTJmMGYxMDhhZDJhM2M2N2Iz
11
+ YmUyNjg1MmZlMDlkNDhkNDU4NjNhNGI5YWI4M2YyYjZkODliY2I=
12
12
  data.tar.gz: !binary |-
13
- YTk5YmNjMTQ0NWFmOTRhNGE5MTIzZDFlYmFhNGQ0MGJkYWIyOThkN2Q0OGNi
14
- YjZkZjg2MWQ2MGUyNjIzNGZlOGM0MDFhNGQyY2M0ODJjYTIyY2IwNjFiNDFh
15
- NmY4MDgxYmRiNDM2MzVkNDU5MDBiOTU3NDgxMGY5YmZiM2QwMmQ=
13
+ ZTVjZjQ3OTNjNDQzOGZmNGY1MTlkZGUwOTkyMWU1NmU5YzE1ODUzMmJlMmQ1
14
+ Y2E5ZjVlYzc0ZjBiMmZhNzdiMGIxZDZjMTIzNzg4ZWIxZDFmNDlmMDEwZDAz
15
+ NWJiMmQzYzM5MWYyZjA1NWU4ZDNjMDNhNGQyZDY2Mjg2YThhMzU=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SmoothOperator [![Code Climate](https://codeclimate.com/repos/536a7b9f6956801228014b02/badges/13f79897976274a9de33/gpa.png)](https://codeclimate.com/repos/536a7b9f6956801228014b02/feed)
1
+ # SmoothOperator [![Code Climate](https://codeclimate.com/github/goncalvesjoao/smooth_operator/badges/gpa.svg)](https://codeclimate.com/github/goncalvesjoao/smooth_operator)
2
2
 
3
3
  Ruby gem, that mimics the ActiveRecord behaviour but through external API's.
4
4
  It's a lightweight and flexible alternative to ActiveResource, that responds to a REST API like you expect it too.
@@ -49,7 +49,7 @@ module SmoothOperator
49
49
  end
50
50
 
51
51
  def save(relative_path = nil, data = {}, options = {})
52
- resource_data = resource_data_for_server(data)
52
+ resource_data = resource_data_for_server(data, options)
53
53
 
54
54
  method = new_record? ? :create : :update
55
55
 
@@ -63,7 +63,7 @@ module SmoothOperator
63
63
  def destroy(relative_path = nil, data = {}, options = {})
64
64
  return false unless persisted?
65
65
 
66
- resource_data = resource_data_for_server(data)
66
+ resource_data = resource_data_for_server(data, options)
67
67
 
68
68
  make_a_persistence_call(:destroy, relative_path, resource_data, options) do |remote_call|
69
69
  @destroyed = true if remote_call.status
@@ -90,15 +90,25 @@ module SmoothOperator
90
90
  end
91
91
  end
92
92
 
93
- def resource_data_for_server(data)
93
+ def resource_data_for_server(data, options)
94
+ data ||= {}
95
+ options ||= {}
96
+
94
97
  resource_data =
95
- self.class.get_option(:resource_data_for_server, false, data)
98
+ self.class.get_option(:resource_data_for_server, false, data, options)
96
99
 
97
100
  if resource_data == false
98
101
  data = Helpers.stringify_keys(data)
102
+
99
103
  resource_data = Helpers.stringify_keys(internal_data_for_server)
100
104
 
101
- { self.class.resource_name.to_s => resource_data }.merge(data)
105
+ resource_name = options[:resource_name] || self.class.resource_name.to_s
106
+
107
+ if Helpers.present?(resource_name)
108
+ { resource_name => resource_data }.merge(data)
109
+ else
110
+ resource_data.merge(data)
111
+ end
102
112
  else
103
113
  resource_data
104
114
  end
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = '1.30.2'
2
+ VERSION = '1.30.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.2
4
+ version: 1.30.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler