culpa 0.6.0.1 → 0.7.0
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 +8 -8
- data/lib/culpa.rb +27 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDI0OTI3ODBhMjhjYjQxODMxODc3ZjJkOTVmM2M1ODhmZDJiZjQ2Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTEzOWU1ZjM3NGJkMDU4M2MwYjJiZDg4NzlhZDZmYzJmNDkyYzE0NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGFkOTA3NzIyODFjODI3M2RjYTA2ODUxMTgyMzkwZDUwNGI2NWMyMjVhZTk1
|
10
|
+
ZTJmOGMyODdlZjg1ODQ5YWI4YjBkMjRmZmJjMTRhN2Q2MjQyNTViMWU1YjM5
|
11
|
+
MjgyYWNiZTA4MmIzZDBhMjBkYTE3MjEwNjhjYmQxNTFkYTJlNmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjRlMGVmYjJiZjU1YmM1MDQ1Nzg1MmUxYjIzNjhjNThkMWRiYTZhYjE4MmQy
|
14
|
+
ZjRkYWNjYjE0NGVkMTNkYmIzZGRjYzI0ZmM2YmRiZDU1OWVmMzc3NzJiZGY1
|
15
|
+
OTY1NDRiMzE1MmJiZWFhMjAyZDNjOTY4MjEwNjU2YjQxMzUxY2I=
|
data/lib/culpa.rb
CHANGED
@@ -7,7 +7,7 @@ require 'envelope'
|
|
7
7
|
require 'path_parser'
|
8
8
|
require 'file_helpers'
|
9
9
|
|
10
|
-
CULPA_VERSION='0.
|
10
|
+
CULPA_VERSION='0.7.0'
|
11
11
|
|
12
12
|
ACTIONS_PATH ||= './actions/*.rb'
|
13
13
|
MODELS_PATH ||= './models/*.rb'
|
@@ -106,16 +106,37 @@ module Culpa
|
|
106
106
|
request = EnvelopeRequest.new(options)
|
107
107
|
bricks = @router[router_method_name]
|
108
108
|
return not_found unless bricks
|
109
|
-
@logger.info "Brickchain determined for #{router_method_name}
|
109
|
+
@logger.info "Brickchain determined for #{router_method_name}"
|
110
110
|
bricks.each do |brick|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
# Iterating over bricks for this request
|
112
|
+
if brick.is_a? String
|
113
|
+
# This brick is a sychronous call, processing call directly.
|
114
|
+
action_class = brick_call brick, envelope, request
|
115
|
+
return do_render(action_class.to_render) if action_class.to_render
|
116
|
+
elsif brick.is_a?(Hash) && brick.has_key?('async')
|
117
|
+
# This brick is a bundle of async bricks, treating it in threads.
|
118
|
+
threads = []
|
119
|
+
brick['async'].each { |async_brick|
|
120
|
+
threads << Thread.new { brick_call(async_brick, envelope, request) }
|
121
|
+
}
|
122
|
+
threads.each { |thread|
|
123
|
+
action_class = thread.value
|
124
|
+
return do_render(action_class.to_render) if action_class.to_render
|
125
|
+
}
|
126
|
+
end
|
115
127
|
end
|
116
128
|
raise NoRenderCalled.new
|
117
129
|
end
|
118
130
|
|
131
|
+
##
|
132
|
+
# Call a brick and get the instancied class of the brick's parent action
|
133
|
+
def brick_call(brick, envelope, request)
|
134
|
+
action_class_name, method_name = brick.split('.')
|
135
|
+
action_class = Actions.const_get(action_class_name).new(envelope, request)
|
136
|
+
action_class.send method_name
|
137
|
+
action_class
|
138
|
+
end
|
139
|
+
|
119
140
|
##
|
120
141
|
# Renders a json or anything else
|
121
142
|
def do_render(to_render)
|