smooth_operator 1.11.1 → 1.11.2
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.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGZkNjkyYmRiYThmY2U0MmIzMWRlN2FkYjMzYzBlMmQ0MTdkMWRjMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzI4M2U5YmI5NzhlYjVkMjIwMGRiYzM2Y2IxNmNiYjI0NTIzYjQ5Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGU4MDc5MjcxZmUyMTg2N2RiNWVlMjBjMTgwNzcwODMxZWJiZDM3YjQ3OThl
|
10
|
+
ODMyZDcyNDNhMzk0YjVkMmZlODZiZjg5NDZlMzY2MzA4Yzk5ZWI0YmViODMx
|
11
|
+
Y2IwMGI0ZTQyZWFhMWU3MmJhNjg1Y2M3YzYxMjZkZDgyYWYwYWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTIwYmQ1YTNjYzliZjJmOTg3YWEyNjczZWZhMWU1YzkwODM2NDJjZGM2YzU4
|
14
|
+
MmNmOWQ2ZjZkNWRiMDQ0MDgxMTY1N2UxYzgxN2ZiNTVmNGFmNzQxOWM0N2M3
|
15
|
+
MWFiY2I1ZThiOTM2MjI1MGI5NmIyZGY4YTU3YTk5YTEyMGJhN2U=
|
@@ -60,14 +60,14 @@ module SmoothOperator
|
|
60
60
|
|
61
61
|
def assign_attributes(_attributes = {}, options = {})
|
62
62
|
return nil unless _attributes.is_a?(Hash)
|
63
|
-
|
63
|
+
|
64
64
|
attributes = _attributes = Helpers.stringify_keys(_attributes)
|
65
65
|
|
66
66
|
if _attributes.include?(self.class.resource_name)
|
67
67
|
attributes = _attributes.delete(self.class.resource_name)
|
68
68
|
@_meta_data = _attributes
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
options.each { |key, value| @_options[key] = value } if options.is_a?(Hash)
|
72
72
|
|
73
73
|
attributes.each { |name, value| push_to_internal_data(name, value, true) }
|
@@ -103,21 +103,20 @@ module SmoothOperator
|
|
103
103
|
attribute_name = attribute_name.to_s
|
104
104
|
|
105
105
|
return nil unless allowed_attribute(attribute_name)
|
106
|
-
|
106
|
+
|
107
107
|
known_attributes.add attribute_name
|
108
|
-
|
108
|
+
|
109
109
|
if internal_data[attribute_name].nil?
|
110
110
|
initiate_internal_data(attribute_name, attribute_value, cast)
|
111
111
|
else
|
112
112
|
update_internal_data(attribute_name, attribute_value, cast)
|
113
113
|
end
|
114
114
|
|
115
|
-
if self.class.respond_to?(:
|
115
|
+
if self.class.respond_to?(:smooth_operator?) && attribute_name == self.class.primary_key
|
116
116
|
new_record?(true)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
|
121
120
|
protected #################### PROTECTED METHODS DOWN BELOW ######################
|
122
121
|
|
123
122
|
def before_initialize(attributes, options); end
|
@@ -14,7 +14,7 @@ module SmoothOperator
|
|
14
14
|
relative_path = resource_path(relative_path)
|
15
15
|
|
16
16
|
if !parent_object.nil? && options[:ignore_parent] != true
|
17
|
-
options[:resources_name] ||= "#{parent_object.class.resources_name}/#{parent_object.
|
17
|
+
options[:resources_name] ||= "#{parent_object.class.resources_name}/#{parent_object.get_primary_key}/#{self.class.resources_name}"
|
18
18
|
end
|
19
19
|
|
20
20
|
self.class.make_the_call(http_verb, relative_path, data, options) do |remote_call|
|
@@ -28,7 +28,7 @@ module SmoothOperator
|
|
28
28
|
if Helpers.absolute_path?(relative_path)
|
29
29
|
Helpers.remove_initial_slash(relative_path)
|
30
30
|
elsif persisted?
|
31
|
-
Helpers.present?(relative_path) ? "#{
|
31
|
+
Helpers.present?(relative_path) ? "#{get_primary_key}/#{relative_path}" : get_primary_key.to_s
|
32
32
|
else
|
33
33
|
relative_path
|
34
34
|
end
|
@@ -9,12 +9,12 @@ module SmoothOperator
|
|
9
9
|
attr_reader :last_remote_call
|
10
10
|
|
11
11
|
|
12
|
-
def
|
13
|
-
get_internal_data(self.class.
|
12
|
+
def get_primary_key
|
13
|
+
get_internal_data(self.class.primary_key)
|
14
14
|
end
|
15
15
|
|
16
16
|
def reload(relative_path = nil, data = {}, options = {})
|
17
|
-
raise 'UnknownPath' if Helpers.blank?(relative_path) && (!respond_to?(self.class.
|
17
|
+
raise 'UnknownPath' if Helpers.blank?(relative_path) && (!respond_to?(self.class.primary_key) || Helpers.blank?(get_primary_key))
|
18
18
|
|
19
19
|
persistence_call(:reload, relative_path, data, options) do |remote_call|
|
20
20
|
block_given? ? yield(remote_call) : remote_call.status
|
@@ -24,7 +24,7 @@ module SmoothOperator
|
|
24
24
|
def new_record?(bypass_cache = false)
|
25
25
|
return @new_record if !bypass_cache && defined?(@new_record)
|
26
26
|
|
27
|
-
@new_record = Helpers.blank?(
|
27
|
+
@new_record = Helpers.blank?(get_primary_key)
|
28
28
|
end
|
29
29
|
|
30
30
|
def destroyed?
|
@@ -101,7 +101,7 @@ module SmoothOperator
|
|
101
101
|
|
102
102
|
hash = serializable_hash(options[:serializable_options]).dup
|
103
103
|
|
104
|
-
hash.delete(self.class.
|
104
|
+
hash.delete(self.class.primary_key)
|
105
105
|
|
106
106
|
{ self.class.resource_name => hash }.merge(data)
|
107
107
|
end
|
@@ -115,11 +115,11 @@ module SmoothOperator
|
|
115
115
|
Helpers.get_instance_variable(self, :methods_vs_http_verbs, METHODS_VS_HTTP_VERBS.dup)
|
116
116
|
end
|
117
117
|
|
118
|
-
def
|
119
|
-
Helpers.get_instance_variable(self, :
|
118
|
+
def primary_key
|
119
|
+
Helpers.get_instance_variable(self, :primary_key, 'id')
|
120
120
|
end
|
121
121
|
|
122
|
-
attr_writer :
|
122
|
+
attr_writer :primary_key
|
123
123
|
|
124
124
|
METHODS_VS_HTTP_VERBS.keys.each do |method|
|
125
125
|
define_method("#{method}_http_verb=") { |http_verb| methods_vs_http_verbs[method] = http_verb }
|
data/lib/smooth_operator.rb
CHANGED
@@ -7,7 +7,6 @@ require "smooth_operator/open_struct"
|
|
7
7
|
require "smooth_operator/finder_methods"
|
8
8
|
|
9
9
|
module SmoothOperator
|
10
|
-
|
11
10
|
class Base < OpenStruct::Base
|
12
11
|
|
13
12
|
extend FinderMethods
|
@@ -19,6 +18,9 @@ module SmoothOperator
|
|
19
18
|
|
20
19
|
self.strict_behaviour = true
|
21
20
|
|
21
|
+
def self.smooth_operator?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
22
25
|
end
|
23
|
-
|
24
26
|
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.11.
|
4
|
+
version: 1.11.2
|
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-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|