File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ def resource_path
3939 def namespace ( namespace )
4040 @namespace = namespace
4141 end
42+
43+ def new_from_response ( client , response , includes = nil )
44+ new ( client ) . tap do |resource |
45+ resource . handle_response ( response )
46+ resource . set_includes ( resource , includes , response . body ) if includes
47+ resource . attributes . clear_changes
48+ end
49+ end
4250 end
4351
4452 # @return [Hash] The resource's attributes
@@ -123,19 +131,16 @@ def to_s
123131
124132 # Compares resources by class and id. If id is nil, then by object_id
125133 def ==( other )
134+ return false unless other
135+
126136 return true if other . object_id == object_id
127137
128- if other && !( other . is_a? ( Data ) || other . is_a? ( Integer ) )
129- warn "Trying to compare #{ other . class } to a Resource from #{ caller . first } "
130- end
138+ return other . id && ( other . id == id ) if other . is_a? ( Data )
131139
132- if other . is_a? ( Data )
133- other . id && other . id == id
134- elsif other . is_a? ( Integer )
135- id == other
136- else
137- false
138- end
140+ return id == other if other . is_a? ( Integer )
141+
142+ warn "Trying to compare #{ other . class } to a Resource
143+ from #{ caller . first } "
139144 end
140145 alias :eql :==
141146
You can’t perform that action at this time.
0 commit comments