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/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/local.rb,
lib/rjr/nodes/multi.rb,
lib/rjr/thread_pool.rb,
lib/rjr/nodes/missing.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
Class Method Summary collapse
Class Method Details
.parse_json(js) ⇒ Object
221 222 223 224 225 226 |
# File 'lib/rjr/common.rb', line 221 def self.parse_json(js) jp = ::JSON.parse js, :create_additions => false return jp unless jp.is_a?(Hash) validate_json_hash(jp) ::JSON.parse js, :create_additions => true end |
.validate_json_class(jc) ⇒ Object
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.validate_json_class(jc) Class.whitelist_json_classes ||= false Class.whitelist_json_classes ? # only permit classes user explicitly authorizes !Class.permitted_json_classes.include?(jc) : # allow any class 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 |
.validate_json_hash(jh) ⇒ Object
210 211 212 213 214 215 216 217 218 219 |
# File 'lib/rjr/common.rb', line 210 def self.validate_json_hash(jh) jh.each { |k,v| if k == ::JSON.create_id && validate_json_class(v) raise ArgumentError, "can't create json class #{v}" elsif v.is_a?(Hash) validate_json_hash(v) end } end |