Class: Fluent::OjOptions
- Inherits:
-
Object
- Object
- Fluent::OjOptions
- Defined in:
- lib/fluent/oj_options.rb
Constant Summary collapse
- OPTIONS =
{ 'bigdecimal_load': :symbol, 'mode': :symbol, 'use_to_json': :bool }
- ALLOWED_VALUES =
{ 'bigdecimal_load': %i[bigdecimal float auto], 'mode': %i[strict null compat json rails custom] }
- DEFAULTS =
{ 'bigdecimal_load': :float, 'mode': :compat, 'use_to_json': true }
- @@available =
false
Class Method Summary collapse
Class Method Details
.available? ⇒ Boolean
24 25 26 |
# File 'lib/fluent/oj_options.rb', line 24 def self.available? @@available end |
.get_options ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fluent/oj_options.rb', line 42 def self. = {} DEFAULTS.each { |key, value| [key] = value } OPTIONS.each do |key, type| env_value = ENV["FLUENT_OJ_OPTION_#{key.upcase}"] next if env_value.nil? cast_value = Fluent::Config.reformatted_value(OPTIONS[key], env_value, { strict: true }) next if cast_value.nil? next if ALLOWED_VALUES[key] && !ALLOWED_VALUES[key].include?(cast_value) [key.to_sym] = cast_value end end |
.load_env ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fluent/oj_options.rb', line 28 def self.load_env = self. begin require 'oj' Oj. = @@available = true rescue LoadError @@available = false end end |