module MultiJson::Options
Public Instance Methods
Source
# File lib/multi_json/options.rb, line 25 def default_dump_options @default_dump_options ||= {}.freeze end
Source
# File lib/multi_json/options.rb, line 21 def default_load_options @default_load_options ||= {}.freeze end
Source
# File lib/multi_json/options.rb, line 17 def dump_options(*) (defined?(@dump_options) && get_options(@dump_options, *)) || default_dump_options end
Source
# File lib/multi_json/options.rb, line 8 def dump_options=(options) OptionsCache.reset @dump_options = options end
Source
# File lib/multi_json/options.rb, line 13 def load_options(*) (defined?(@load_options) && get_options(@load_options, *)) || default_load_options end
Source
# File lib/multi_json/options.rb, line 3 def load_options=(options) OptionsCache.reset @load_options = options end
Private Instance Methods
Source
# File lib/multi_json/options.rb, line 31 def get_options(options, *) return handle_callable_options(options, *) if options_callable?(options) handle_hashable_options(options) end
Source
# File lib/multi_json/options.rb, line 41 def handle_callable_options(options, *) options.arity.zero? ? options.call : options.call(*) end
Source
# File lib/multi_json/options.rb, line 45 def handle_hashable_options(options) options.respond_to?(:to_hash) ? options.to_hash : nil end
Source
# File lib/multi_json/options.rb, line 37 def options_callable?(options) options.respond_to?(:call) end