strobe 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/strobe/association.rb +17 -8
- data/lib/strobe/collection.rb +2 -1
- data/lib/strobe/resource/base.rb +9 -15
- data/lib/strobe/resource/collection.rb +2 -2
- data/lib/strobe/resources/application.rb +7 -10
- data/lib/strobe/version.rb +1 -1
- metadata +2 -2
data/lib/strobe/association.rb
CHANGED
@@ -41,10 +41,15 @@ module Strobe
|
|
41
41
|
return item unless targets = params[target_pluralized]
|
42
42
|
|
43
43
|
if collection?
|
44
|
-
|
44
|
+
collection = item[name.to_s] = []
|
45
|
+
id, key = item["id"], "#{source.singular_resource_name}_id"
|
46
|
+
|
47
|
+
targets.each do |target|
|
48
|
+
collection << target if target[key] == id
|
49
|
+
end if id
|
45
50
|
else
|
46
51
|
if id = item["#{name}_id"]
|
47
|
-
|
52
|
+
item.merge!(name.to_s => targets.find { |t| t["id"] == id })
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
@@ -80,16 +85,21 @@ module Strobe
|
|
80
85
|
ruby << "def #{name}=(val)"
|
81
86
|
|
82
87
|
if collection?
|
83
|
-
|
84
|
-
ruby << "
|
85
|
-
|
88
|
+
ruby << " if val.is_a?(Array)"
|
89
|
+
ruby << " @__#{name} = Strobe::Collection.new( " \
|
90
|
+
" #{target_name}, { '#{source.singular_resource_name}_id' " \
|
91
|
+
" => self[:id] }, val)"
|
92
|
+
ruby << " elsif val.is_a?(Strobe::Collection)"
|
93
|
+
ruby << " @__#{name} = val"
|
94
|
+
ruby << " else"
|
95
|
+
ruby << " raise 'invalid association type for #{name}='"
|
96
|
+
ruby << " end"
|
86
97
|
else
|
87
|
-
|
88
98
|
ruby << " if val"
|
89
99
|
ruby << " if val.is_a?(Hash)"
|
90
100
|
ruby << " val = #{target_name}.new(val)"
|
91
101
|
ruby << " elsif !val.is_a?(#{target_name})"
|
92
|
-
ruby << " raise '
|
102
|
+
ruby << " raise 'invalid association type for #{name}='"
|
93
103
|
ruby << " end"
|
94
104
|
|
95
105
|
ruby << " self[:#{name}_id] = val[:id]" if autoload?
|
@@ -98,7 +108,6 @@ module Strobe
|
|
98
108
|
ruby << " self[:#{name}_id] = nil" if autoload?
|
99
109
|
ruby << " @__#{name} = nil"
|
100
110
|
ruby << " end"
|
101
|
-
|
102
111
|
end
|
103
112
|
|
104
113
|
ruby << "end"
|
data/lib/strobe/collection.rb
CHANGED
data/lib/strobe/resource/base.rb
CHANGED
@@ -143,13 +143,16 @@ module Strobe
|
|
143
143
|
def merge!(params)
|
144
144
|
params = with_indifferent_access(params || {})
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
self.class.associations.each do |key, assoc|
|
147
|
+
next unless params.key?(key)
|
148
|
+
value = params.delete(key)
|
149
|
+
|
150
|
+
if assoc.collection? || Base === value
|
151
|
+
send("#{key}=", value)
|
152
|
+
elsif inst = send(key)
|
153
|
+
inst.merge!(value)
|
151
154
|
else
|
152
|
-
send("#{
|
155
|
+
send("#{key}=", value)
|
153
156
|
end
|
154
157
|
end
|
155
158
|
|
@@ -279,15 +282,6 @@ module Strobe
|
|
279
282
|
val
|
280
283
|
end
|
281
284
|
end
|
282
|
-
|
283
|
-
def extract_on_associations(params)
|
284
|
-
{}.tap do |ret|
|
285
|
-
self.class.associations.keys.each do |key|
|
286
|
-
next unless params.key?(key)
|
287
|
-
ret[key] = params.delete(key)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
285
|
end
|
292
286
|
end
|
293
287
|
end
|
@@ -86,14 +86,14 @@ module Strobe
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def denormalize_params(params)
|
89
|
-
if coll = params
|
89
|
+
if coll = params.delete(pluralized_root)
|
90
90
|
coll.map do |item|
|
91
91
|
associations.each do |n, assoc|
|
92
92
|
item = assoc.denormalize_params(item, params)
|
93
93
|
end
|
94
94
|
item
|
95
95
|
end
|
96
|
-
elsif item = params
|
96
|
+
elsif item = params.delete(root)
|
97
97
|
associations.each do |n, assoc|
|
98
98
|
item = assoc.denormalize_params(item, params)
|
99
99
|
end
|
@@ -14,7 +14,7 @@ module Strobe
|
|
14
14
|
has n, :teams
|
15
15
|
has n, :users
|
16
16
|
has n, :deploys
|
17
|
-
has n, :platform_installs
|
17
|
+
has n, :platform_installs, :include => true
|
18
18
|
|
19
19
|
filter :path
|
20
20
|
|
@@ -25,10 +25,11 @@ module Strobe
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def web_install
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
@web_install ||= begin
|
29
|
+
install = self.platform_installs.detect { |p| p.web? }
|
30
|
+
raise "Application does not have web platform" unless install
|
31
|
+
install
|
32
|
+
end
|
32
33
|
end
|
33
34
|
|
34
35
|
def web_url
|
@@ -40,10 +41,6 @@ module Strobe
|
|
40
41
|
web_url
|
41
42
|
else
|
42
43
|
uri = web_install['environment_uri']
|
43
|
-
|
44
|
-
# TODO: remove next line when environment_uri stuff is released
|
45
|
-
uri = web_url if uri.blank?
|
46
|
-
|
47
44
|
"#{environment}.#{uri}"
|
48
45
|
end
|
49
46
|
end
|
@@ -51,7 +48,7 @@ module Strobe
|
|
51
48
|
def set_web_url!(url)
|
52
49
|
return if url.blank?
|
53
50
|
install = web_install
|
54
|
-
install['url'] = url
|
51
|
+
install['url'] = install['install_uri'] = url
|
55
52
|
install.save!
|
56
53
|
end
|
57
54
|
|
data/lib/strobe/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: strobe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Carl Lerche
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-03 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|