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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/culpa.rb +27 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjMxNzJiMjhkMzhkZjk1YmZmYmQwMWQyOGU5MDlmYjAwNWRjYzZmNA==
4
+ ZDI0OTI3ODBhMjhjYjQxODMxODc3ZjJkOTVmM2M1ODhmZDJiZjQ2Mg==
5
5
  data.tar.gz: !binary |-
6
- MWZhZjM2OWJmYjMyZDc2N2M5MWY3YzE3NGFlYjliNDdlM2FhMjAxMQ==
6
+ OTEzOWU1ZjM3NGJkMDU4M2MwYjJiZDg4NzlhZDZmYzJmNDkyYzE0NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWVkYjk0Mzg4YTY4N2UwMzRhMmI5M2UxYWZlMWE1Y2E0OWFhZWVlNzczZGM2
10
- NTc3MWRlNTQwZTU4NTVlOTU2OWIxMjg2ZjAzMGQ4Y2UzYzI1ZjgwNzdjNGEy
11
- MDNlNWIzZTUzYmZjZWZjMzNlZmNkY2JkNjVhZDQ5NjI4NmU0NjM=
9
+ NGFkOTA3NzIyODFjODI3M2RjYTA2ODUxMTgyMzkwZDUwNGI2NWMyMjVhZTk1
10
+ ZTJmOGMyODdlZjg1ODQ5YWI4YjBkMjRmZmJjMTRhN2Q2MjQyNTViMWU1YjM5
11
+ MjgyYWNiZTA4MmIzZDBhMjBkYTE3MjEwNjhjYmQxNTFkYTJlNmU=
12
12
  data.tar.gz: !binary |-
13
- ZmQ2YjBhYWFmNmY2NjViMTM3NWUyNTRmZjY1MTQxYzRjNTI3M2Q4NDdiMWU4
14
- MzFiMjc1MDRkMTBmZWYxMDMyNzM4MTQzMGRjYjUzNDI0NGU2NmZjNjZiYmU0
15
- ZDY2NGEyZjRjYjFkNmI3ZmViZjhjMDA1MmUxZWFjNGE3YmRjMmY=
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.6.0.1'
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} :\n#{bricks.join("\n")}\n"
109
+ @logger.info "Brickchain determined for #{router_method_name}"
110
110
  bricks.each do |brick|
111
- action_class_name, method_name = brick.split('.')
112
- action_class = Actions.const_get(action_class_name).new(envelope, request)
113
- action_class.send method_name
114
- return do_render action_class.to_render if action_class.to_render
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culpa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy SEBAN