arrest 0.0.35 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -197,13 +197,8 @@ module Arrest
197
197
  end
198
198
 
199
199
  send :define_method, method_name do
200
- if @child_collections == nil
201
- @child_collections = {}
202
- end
203
- if @child_collections[method_name] == nil
204
- @child_collections[method_name] = ChildCollection.new(self, (StringUtils.classify (StringUtils.singular clazz_name)))
205
- end
206
-
200
+ @child_collections ||= {}
201
+ @child_collections[method_name] ||= ChildCollection.new(self, (StringUtils.classify (StringUtils.singular clazz_name)))
207
202
  @child_collections[method_name]
208
203
  end
209
204
  end
@@ -213,7 +208,6 @@ module Arrest
213
208
  class_eval "def #{method_name}; self.parent; end"
214
209
  end
215
210
 
216
-
217
211
  def scope(name, options = {}, &block)
218
212
  if @scopes == nil
219
213
  @scopes = []
@@ -284,7 +278,9 @@ module Arrest
284
278
 
285
279
  def reload
286
280
  @has_many_collections = {}
287
- internal_reload
281
+ @child_collections = {}
282
+ hash = internal_reload
283
+ self.attributes= hash
288
284
  end
289
285
 
290
286
  def new_record?
@@ -188,11 +188,5 @@ module Arrest
188
188
  @stubbed
189
189
  end
190
190
 
191
- protected
192
- def internal_reload
193
- hash = self.class.find(self.context, self.id).to_hash
194
- self.attributes= hash
195
- end
196
-
197
191
  end
198
192
  end
@@ -16,11 +16,10 @@ module Arrest
16
16
  (resource_path_for parent) + '/' + scope_name.to_s
17
17
  end
18
18
 
19
- def build parent, hash
19
+ def build(parent, hash)
20
20
  self.new(parent.context, parent, hash)
21
21
  end
22
22
 
23
-
24
23
  def all_for(parent)
25
24
  raise "Parent has no id yet" unless parent.id
26
25
  begin
@@ -36,10 +35,10 @@ module Arrest
36
35
  raise "find cannot be executed for child resources - use find_for with a parent"
37
36
  end
38
37
 
39
- def find_for(context, parent,id)
38
+ def find_for(context, parent, id)
40
39
  r = source().get_one(context, "#{self.resource_path_for(parent)}/#{id}")
41
40
  body = body_root(r)
42
- self.build(body)
41
+ self.build(parent, body)
43
42
  end
44
43
 
45
44
  def filter name, &aproc
@@ -58,7 +57,7 @@ module Arrest
58
57
  super name
59
58
  if block_given?
60
59
  send :define_singleton_method, name do |parent|
61
- self.all_for(parent).select &block
60
+ self.all_for(parent).select &block
62
61
  end
63
62
  else
64
63
  send :define_singleton_method, name do |parent|
@@ -87,7 +86,12 @@ module Arrest
87
86
  raise "stubbing for child resource isnt supported yet"
88
87
  end
89
88
 
90
-
89
+ protected
90
+ def internal_reload
91
+ @parent.reload
92
+ self.class.find_for(self.context, self.parent, self.id).to_hash
93
+ end
91
94
  end
92
95
  end
93
96
 
97
+
@@ -111,7 +111,6 @@ module Arrest
111
111
  n
112
112
  end
113
113
 
114
-
115
114
  def delete_all(context)
116
115
  source().delete_all(context, self.resource_path)
117
116
  end
@@ -125,6 +124,10 @@ module Arrest
125
124
  self.class.resource_path + '/' + self.id.to_s
126
125
  end
127
126
 
127
+ protected
128
+ def internal_reload
129
+ self.class.find(self.context, self.id).to_hash
130
+ end
128
131
  end
129
132
  end
130
133
 
@@ -1,3 +1,3 @@
1
1
  module Arrest
2
- VERSION = "0.0.35"
2
+ VERSION = "0.0.36"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-01 00:00:00.000000000Z
12
+ date: 2012-03-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &17815000 !ruby/object:Gem::Requirement
16
+ requirement: &22880140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17815000
24
+ version_requirements: *22880140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &17814280 !ruby/object:Gem::Requirement
27
+ requirement: &22879620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.7.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *17814280
35
+ version_requirements: *22879620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activemodel
38
- requirement: &17813440 !ruby/object:Gem::Requirement
38
+ requirement: &22878840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *17813440
46
+ version_requirements: *22878840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &17812760 !ruby/object:Gem::Requirement
49
+ requirement: &22878180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *17812760
57
+ version_requirements: *22878180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &17812180 !ruby/object:Gem::Requirement
60
+ requirement: &22877620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *17812180
68
+ version_requirements: *22877620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
- requirement: &17811700 !ruby/object:Gem::Requirement
71
+ requirement: &22877160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *17811700
79
+ version_requirements: *22877160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &17811180 !ruby/object:Gem::Requirement
82
+ requirement: &22876660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '2'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *17811180
90
+ version_requirements: *22876660
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rr
93
- requirement: &17810700 !ruby/object:Gem::Requirement
93
+ requirement: &22876200 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *17810700
101
+ version_requirements: *22876200
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &17810220 !ruby/object:Gem::Requirement
104
+ requirement: &22875660 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *17810220
112
+ version_requirements: *22875660
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rack
115
- requirement: &17809620 !ruby/object:Gem::Requirement
115
+ requirement: &22875120 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *17809620
123
+ version_requirements: *22875120
124
124
  description: Consume a rest API in a AR like fashion
125
125
  email:
126
126
  - axel.tetzlaff@fortytools.com