class MarkMapper::OptionsHash
Attributes
options[R]
Private: The Hash
that stores instance options
source[R]
Private: The Hash
that stores the query options
Public Class Methods
new(hash={}, options={})
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 16 def initialize(hash={}, options={}) @source = {} @options = options hash.each { |key, value| self[key] = value } end
Public Instance Methods
==(other)
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 47 def ==(other) @source == other.source end
[](key)
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 31 def [](key) @source[key] end
[]=(key, value)
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 36 def []=(key, value) key = normalized_key(key) @source[key] = normalized_value(key, value) end
fields?()
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 57 def fields? !self[:fields].nil? end
initialize_copy(original)
click to toggle source
Calls superclass method
# File lib/mark_mapper/options_hash.rb, line 22 def initialize_copy(original) super @source = @source.dup @source.each do |key, value| self[key] = value.clone if value.duplicable? end end
key_normalizer()
click to toggle source
Private
# File lib/mark_mapper/options_hash.rb, line 83 def key_normalizer @key_normalizer ||= @options.fetch(:key_normalizer) { Normalizers::HashKey.new({ :order => :sort, :select => :fields, :offset => :skip, :id => :_id, }) } end
keys()
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 42 def keys @source.keys end
merge(other)
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 62 def merge(other) self.class.new(to_hash.merge(other.to_hash)) end
merge!(other)
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 67 def merge!(other) other.to_hash.each { |key, value| self[key] = value } self end
normalized_key(key)
click to toggle source
Private
# File lib/mark_mapper/options_hash.rb, line 73 def normalized_key(key) key_normalizer.call(key) end
normalized_value(key, value)
click to toggle source
Private
# File lib/mark_mapper/options_hash.rb, line 78 def normalized_value(key, value) value_normalizer.call(key, value) end
to_hash()
click to toggle source
Public
# File lib/mark_mapper/options_hash.rb, line 52 def to_hash @source end
value_normalizer()
click to toggle source
Private
# File lib/mark_mapper/options_hash.rb, line 95 def value_normalizer @value_normalizer ||= @options.fetch(:value_normalizer) { Normalizers::OptionsHashValue.new({ :key_normalizer => key_normalizer, }) } end