Module: RJR
- Defined in:
- lib/rjr/errors.rb,
lib/rjr/node.rb,
lib/rjr/common.rb,
lib/rjr/common.rb,
lib/rjr/message.rb,
lib/rjr/version.rb,
lib/rjr/nodes/tcp.rb,
lib/rjr/nodes/web.rb,
lib/rjr/dispatcher.rb,
lib/rjr/em_adapter.rb,
lib/rjr/nodes/amqp.rb,
lib/rjr/nodes/easy.rb,
lib/rjr/nodes/unix.rb,
lib/rjr/nodes/local.rb,
lib/rjr/nodes/multi.rb,
lib/rjr/thread_pool.rb,
lib/rjr/nodes/missing.rb,
lib/rjr/nodes/template.rb,
lib/rjr/nodes/ws.rb
Overview
Thread Pool (second implementation)
Copyright © 2010-2013 Mohammed Morsi <[email protected]> Licensed under the Apache License, Version 2.0
Defined Under Namespace
Modules: Errors, MessageMixins, Nodes
Classes: Dispatcher, EMAdapter, Logger, MessageUtil, Node, NodeCallback, NotificationMessage, Request, RequestMessage, ResponseMessage, Result, ThreadPool, ThreadPoolJob
Constant Summary
collapse
- VERSION =
'0.18.1'
Class Method Summary
collapse
Class Method Details
.invalid_json_class?(jc) ⇒ Boolean
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/rjr/common.rb', line 191
def self.invalid_json_class?(jc)
Class.whitelist_json_classes ||= false
Class.whitelist_json_classes ?
!Class.permitted_json_classes.include?(jc) :
jc.to_s.split(/::/).inject(Object) do |p,c|
case
when c.empty? then p
when p.constants.collect { |c| c.to_s }.include?(c)
then p.const_get(c)
else
nil
end
end.nil?
end
|
.parse_json(js) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
|
# File 'lib/rjr/common.rb', line 232
def self.parse_json(js)
jp = ::JSON.parse js, :create_additions => false
if jp.is_a?(Array)
validate_json_array(jp)
elsif jp.is_a?(Hash)
validate_json_hash(jp)
else
return jp
end
::JSON.parse js, :create_additions => true
end
|
.validate_json_array(ja) ⇒ Object
222
223
224
225
226
227
228
229
230
|
# File 'lib/rjr/common.rb', line 222
def self.validate_json_array(ja)
ja.each { |jai|
if jai.is_a?(Array)
validate_json_array(jai)
elsif jai.is_a?(Hash)
validate_json_hash(jai)
end
}
end
|
.validate_json_hash(jh) ⇒ Object
210
211
212
213
214
215
216
217
218
219
220
|
# File 'lib/rjr/common.rb', line 210
def self.validate_json_hash(jh)
jh.each { |k,v|
if k == ::JSON.create_id && invalid_json_class?(v)
raise ArgumentError, "can't create json class #{v}"
elsif v.is_a?(Array)
validate_json_array(v)
elsif v.is_a?(Hash)
validate_json_hash(v)
end
}
end
|