Module: Rollbar::JSON
- Extended by:
- JSON
- Included in:
- JSON
- Defined in:
- lib/rollbar/json.rb,
lib/rollbar/json/oj.rb,
lib/rollbar/json/default.rb
Defined Under Namespace
Instance Attribute Summary collapse
Instance Method Summary collapse
- #adapter_options ⇒ Object
- #detect_multi_json_adapter ⇒ Object
- #dump(object) ⇒ Object
- #find_options_module ⇒ Object
- #load(string) ⇒ Object
-
#multi_json_adapter_module_name ⇒ Object
MultiJson adapters have this name structure: “MultiJson::Adapters::AdapterModule”.
- #with_adapter(&block) ⇒ Object
Instance Attribute Details
#options_module ⇒ Object
40 41 42 |
# File 'lib/rollbar/json.rb', line 40 def @options_module ||= end |
Instance Method Details
#adapter_options ⇒ Object
36 37 38 |
# File 'lib/rollbar/json.rb', line 36 def . end |
#detect_multi_json_adapter ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rollbar/json.rb', line 29 def detect_multi_json_adapter = {} [:adapter] = :oj if defined?(::Oj) MultiJson.current_adapter() end |
#dump(object) ⇒ Object
17 18 19 |
# File 'lib/rollbar/json.rb', line 17 def dump(object) with_adapter { MultiJson.dump(object, ) } end |
#find_options_module ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/rollbar/json.rb', line 44 def module_name = multi_json_adapter_module_name if LanguageSupport.const_defined?(Rollbar::JSON, module_name, false) LanguageSupport.const_get(Rollbar::JSON, module_name, false) else Default end end |
#load(string) ⇒ Object
21 22 23 |
# File 'lib/rollbar/json.rb', line 21 def load(string) with_adapter { MultiJson.load(string, ) } end |
#multi_json_adapter_module_name ⇒ Object
MultiJson adapters have this name structure: “MultiJson::Adapters::AdapterModule”
Ex: MultiJson::Adapters::Oj Ex: MultiJson::Adapters::JsonGem
In this method we just get the last module name.
61 62 63 |
# File 'lib/rollbar/json.rb', line 61 def multi_json_adapter_module_name detect_multi_json_adapter.name[/^MultiJson::Adapters::(.*)$/, 1] end |
#with_adapter(&block) ⇒ Object
25 26 27 |
# File 'lib/rollbar/json.rb', line 25 def with_adapter(&block) MultiJson.with_adapter(detect_multi_json_adapter, &block) end |