Class: MapWithIndifferentAccess::Map
- Inherits:
-
Object
- Object
- MapWithIndifferentAccess::Map
- Extended by:
- Forwardable
- Includes:
- WrapsCollection
- Defined in:
- lib/map_with_indifferent_access/map.rb
Instance Attribute Summary collapse
Attributes included from WrapsCollection
Class Method Summary collapse
-
.try_convert(from_obj) ⇒ Map?
Try to convert
from_objinto a Map. -
.try_deconstruct(obj) ⇒ Hash?
Try to convert
obj, which might be a Map into aHash.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#[](key) ⇒ Object
Returns the externalization of the value from the target's #inner_map entry having a key that conforms to the given
keyif applicable. -
#[]=(key, value) ⇒ Object
(also: #store)
Creates an entry or replaces the value of an existing entry in the target's #inner_map
Hash. -
#any? ⇒ Boolean
Iterates over entries in the target Map, passing a
[ key, externalized_value ]Arrayto the block for each of those, and returnstruewhen the block returnstruefor any entry. -
#assoc(obj) ⇒ Array?
Searches through the map, comparing the conformation of
objwith each entry's key using==. -
#compare_by_identity ⇒ Map
Makes the target's #inner_map
Hashcompare its keys by their identities, i.e. -
#compare_by_identity? ⇒ Boolean
Returns true if the target's #inner_map
Hashwill compare its keys by their identities. -
#conform_key(given_key) ⇒ Object
Returns the
given_keyobject if it is a key in the target's #inner_mapHashor if neithergiven_keynor itsString/Symbolalternative is a key in the #inner_map. -
#default(key = nil) ⇒ Object
Returns the default value, the value that would be returned by
<target>[key]if the conformation ofkeydid not exist in the target. -
#default=(obj) ⇒ Object
Sets the default value returned from the target's #inner_map
Hashfor a key that does not exist to be the internlization ofobj. -
#default_proc ⇒ Proc?
If the target Map's #inner_map
Hashdoes not have a default proc assigned, then this returnsnil. -
#default_proc=(proc_obj) ⇒ Object
Sets the #inner_map
Hash's default proc to a wrapper aroundproc_objthat passes the target Map and the key as parameters and returns the internalization of the wrapped proc's block. -
#delete(key) ⇒ Object
Delete the externalization of the value associated with the conformation of the given
keyor default value. -
#delete_if ⇒ Object
Deletes every entry for which the block evaluates to
truegiven the entry's key and externalized value. -
#each ⇒ Object
(also: #each_pair)
When a block argument is given, calls the block once for each of the target's entries, passing the entry's key and externalized value as parameters, and then returns the target object.
-
#each_key ⇒ MapWithIndifferentAccess::Map
When a block argument is given, calls the block once for each of the target's keys, passing the key as a parameter, and then returns the target object.
-
#each_value ⇒ MapWithIndifferentAccess::Map
When a block argument is given, calls the block once for each of the target's entries, passing externalization the entry value as a parameter, and then returns the target.
- #fetch(key, *more_args) ⇒ Object
- #flatten(*args) ⇒ List
-
#has_value?(value) ⇒ Boolean
(also: #value?)
Returns
trueif the internalization ofvalueis present for some key in the target. -
#initialize(basis = {}) ⇒ Map
constructor
Initializes a new Map that encapsulates a new empty
Arrayor theArraycoerced from the givenbasis. - #inject(*args, &block) ⇒ Object
-
#invert ⇒ Map
Returns a new Map with an #inner_map
Hashcreated by using the the target's #inner_map's values as keys and keys as values. -
#keep_if ⇒ Object
Deletes every entry for which the block evaluates to
false, given the entry's key and externalized value. -
#key(value) ⇒ Object?
Returns the key for an entry, the externalization of which is equal to the externalization of
value. -
#key?(key) ⇒ Boolean
(also: #has_key?, #include?, #member?)
Returns
trueif the conformation ofkeyis present in the target Map. -
#keys ⇒ Array
Returns a new
Arraypopulated with the keys from this Map. - #merge(other) ⇒ Map
- #merge!(other) ⇒ Map (also: #update)
-
#rassoc(value) ⇒ Array?
Searches through the map, comparing the externalization of
valuewith the externalized value of each entry using==.Returns a 2-element array containing the key and externalized value from the matching element or returns ornilif no match is found. -
#rehash ⇒ Map
Rebuilds the target's #inner_map
Hashbased on the current#hashvalues for each key. -
#reject ⇒ Object
Returns a new Map consisting of entries for which the block returns
false, given the entry's key and externalized value. -
#reject! ⇒ Object
Equivalent to #delete_if, but returns
nilif no changes were made. -
#replace(other) ⇒ Map
Replace the contents of the target's #inner_map
Hashwith the deconstruction of the givenHash-like object. -
#select ⇒ Object
Returns a new Map consisting of entries for which the block returns
true, given the entry's key and externalized value. -
#select! ⇒ Object
Equivalent to #keep_if, but returns
nilif no changes were made. - #shift ⇒ Array, Object
-
#to_h ⇒ Object
Alias for WrapsCollection#inner_collection.
- #to_hash ⇒ Object
- #values ⇒ List
-
#values_at(*keys) ⇒ List
Return a List containing the values of entries matching the given keys.
Methods included from WrapsCollection
#_frozen?, #clear, #empty?, #eql?, #freeze, #frozen?, #hash, #length, #size, #taint, #tainted?, #trust, #untaint, #untrust, #untrusted?
Constructor Details
#initialize(basis = {}) ⇒ Map
Initializes a new MapWithIndifferentAccess::Map that encapsulates a new
empty Array or the Array coerced from the given
basis.
When a MapWithIndifferentAccess::Map is given as a basis, this results on the given and new instances sharing the same #inner_map. There is no obvious reason to do that on purpose, but there is also no likely harm in allowing it to happen.
101 102 103 104 105 106 107 |
# File 'lib/map_with_indifferent_access/map.rb', line 101 def initialize(basis={}) use_basis = basis use_basis = basis.inner_map if self.class === basis use_basis = Hash.try_convert( use_basis ) raise ArgumentError, "Could not convert #{basis.inspect} into a Hash" unless use_basis @inner_collection = use_basis end |
Instance Attribute Details
#inner_array ⇒ Array
Alias for WrapsCollection#inner_collection. The encapsulated Hash
instance.
54 |
# File 'lib/map_with_indifferent_access/map.rb', line 54 alias inner_map inner_collection |
Class Method Details
.try_convert(from_obj) ⇒ Map?
Try to convert from_obj into a MapWithIndifferentAccess::Map.
22 23 24 25 26 27 28 29 |
# File 'lib/map_with_indifferent_access/map.rb', line 22 def self.try_convert(from_obj) if self === from_obj from_obj else hash = Hash.try_convert( from_obj ) new( hash ) if hash end end |
.try_deconstruct(obj) ⇒ Hash?
Try to convert obj, which might be a MapWithIndifferentAccess::Map into a Hash.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/map_with_indifferent_access/map.rb', line 38 def self.try_deconstruct(obj) if self === obj obj.inner_map elsif obj.respond_to?(:to_hash ) h = obj.to_hash Hash === h ? h : nil else nil end end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the entries in other (a MapWithIndifferentAccess::Map, Hash,
or other Hash-like object) are equal in numer and
equivalent to the entries in the target MapWithIndifferentAccess::Map.
Entries are equivalent if their keys are equivalent with
String/Symbolic indifference and their externalized
values are equal using ==.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/map_with_indifferent_access/map.rb', line 332 def ==(other) return true if equal?( other ) other = self.class.try_convert( other ) return false unless other return true if inner_map == other.inner_map return false if length != other.length each do |(key, value)| other_val = other.fetch(key) { return false } return false unless value == other_val end true end |
#[](key) ⇒ Object
Returns the externalization of the value from the target's
#inner_map entry having a key that conforms to the given
key if applicable.
When there is no entry with a conforming key, returns the
externalization of the #inner_map Hash's default value
for the given key (normally nil).
190 191 192 193 194 |
# File 'lib/map_with_indifferent_access/map.rb', line 190 def[](key) key = conform_key( key ) value = inner_map[ key ] Values >> value end |
#[]=(key, value) ⇒ Object Also known as: store
Creates an entry or replaces the value of an existing entry
in the target's #inner_map Hash.
When the key conforms to a key in the target map, then the
value of the matching entry in the target's #inner_map is
replaced with the internalization of value.
When key does not conform to a key in the target map, then
a new entry is added using the given key and the
internalization of value.
Returns the given value.
171 172 173 174 175 176 |
# File 'lib/map_with_indifferent_access/map.rb', line 171 def[]=(key, value) key = conform_key( key ) intern_value = Values << value inner_map[ key ] = intern_value value end |
#any? {|pair| ... } ⇒ Boolean #any? ⇒ Boolean
Iterates over entries in the target MapWithIndifferentAccess::Map, passing a
[ key, externalized_value ] Array to the block
for each of those, and returns true when the block
returns true for any entry.
|
|
# File 'lib/map_with_indifferent_access/map.rb', line 135
|
#assoc(obj) ⇒ Array?
Searches through the map, comparing the conformation of
obj with each entry's key using ==. Returns a 2-element
array containing the key and externalized value from the
matching element or returns or nil if no match is found.
606 607 608 609 610 611 612 613 614 |
# File 'lib/map_with_indifferent_access/map.rb', line 606 def assoc(obj) obj = conform_key( obj ) entry = inner_map.assoc( obj ) unless entry.nil? value = Values >> entry[ 1 ] entry[ 1 ] = value end entry end |
#compare_by_identity ⇒ Map
Makes the target's #inner_map Hash compare its keys by
their identities, i.e. it will consider exact same objects
as same keys.
Not particularly useful for a MapWithIndifferentAccess::Map, but included for
conformance with the Hash API.
783 784 785 786 |
# File 'lib/map_with_indifferent_access/map.rb', line 783 def compare_by_identity inner_map.compare_by_identity self end |
#compare_by_identity? ⇒ Boolean
Returns true if the target's #inner_map Hash will
compare its keys by their identities.
Not particularly useful for a MapWithIndifferentAccess::Map, but included for
conformance with the Hash API.
798 |
# File 'lib/map_with_indifferent_access/map.rb', line 798 def_delegator :inner_map, :compare_by_identity? |
#conform_key(given_key) ⇒ Object
Returns the given_key object if it is a key in the target's
#inner_map Hash or if neither given_key nor its
String/Symbol alternative is a key in the #inner_map.
When given_key is a String that is not a key in the
target's #inner_map, returns the symbolization of
given_key if that symbolization is a key in the
#inner_map.
When given_key is a Symbol that is not a key in the
target's #inner_map, returns the stringification of
given_key if that stringification is a key in the
#inner_map.
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/map_with_indifferent_access/map.rb', line 122 def conform_key(given_key) case given_key when String alt_key = inner_map.key?( given_key ) ? given_key : given_key.to_sym inner_map.key?( alt_key ) ? alt_key : given_key when Symbol alt_key = inner_map.key?( given_key ) ? given_key : "#{given_key}" inner_map.key?( alt_key ) ? alt_key : given_key else given_key end end |
#default(key = nil) ⇒ Object
Returns the default value, the value that would be returned
by <target>[key] if the conformation of key did not exist
in the target.
268 269 270 271 |
# File 'lib/map_with_indifferent_access/map.rb', line 268 def default(key = nil) inner_default = inner_map.default( key ) Values >> inner_default end |
#default=(obj) ⇒ Object
Sets the default value returned from the target's
#inner_map Hash for a key that does not exist to
be the internlization of obj.
259 260 261 |
# File 'lib/map_with_indifferent_access/map.rb', line 259 def default=(obj) inner_map.default = Values << obj end |
#default_proc ⇒ Proc?
If the target MapWithIndifferentAccess::Map's #inner_map Hash does not have a
default proc assigned, then this returns nil.
If Proc has been previously assigned to the target MapWithIndifferentAccess::Map
using #default_proc= and is is still applicable, then
that Proc is returned.
If no Proc was assigned to the target MapWithIndifferentAccess::Map or that
assignment is no longer applicable, but the #inner_map
Hash has a default proc, then a wrapper around that
Proc is returned that accepts a Map or Hash-like
object and a key, passing the Map-deconstruction of the
Map/Hash and the unmodified key value to the underlying
Proc, finally returning the externalization of the value
returned from the call to the underlying Proc.
310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/map_with_indifferent_access/map.rb', line 310 def default_proc return nil unless inner_map.default_proc unless inner_map.default_proc.equal?( _inner_proc_for_default_proc ) self._default_proc = nil end return _default_proc if _default_proc _default_proc = ->(map,key){ hash = self.class.try_deconstruct( map ) value = inner_map.default_proc.call( hash, key ) Values >> value } end |
#default_proc=(proc_obj) ⇒ Object
Sets the #inner_map Hash's default proc to a wrapper
around proc_obj that passes the target MapWithIndifferentAccess::Map and the key
as parameters and returns the internalization of the
wrapped proc's block.
When running in Ruby 2.x or newer, the default proc can
also be cleared by passing nil for proc_obj.
283 284 285 286 287 288 289 290 291 |
# File 'lib/map_with_indifferent_access/map.rb', line 283 def default_proc=(proc_obj) inner_proc = ->(_, key){ Values << proc_obj.call( self, key ) } inner_map.default_proc = inner_proc self._default_proc = proc_obj self._inner_proc_for_default_proc = inner_proc proc_obj end |
#delete(key) ⇒ Object #delete(key) {|key| ... } ⇒ Object
Delete the externalization of the value associated with the
conformation of the given key or default value.
427 428 429 430 431 432 433 434 435 |
# File 'lib/map_with_indifferent_access/map.rb', line 427 def delete(key) key = conform_key( key ) value = if block_given? inner_map.delete( key ) { |key| yield key } else inner_map.delete( key ) end Values >> value end |
#delete_if {|key, value| ... } ⇒ Map #delete_if ⇒ Enumerator
Deletes every entry for which the block evaluates to
true given the entry's key and externalized value.
If no block is given, then an Enumerator is returned
instead.
500 501 502 503 504 505 506 507 508 509 |
# File 'lib/map_with_indifferent_access/map.rb', line 500 def delete_if return to_enum(:delete_if ) unless block_given? inner_map.delete_if do |key, value| value = Values >> value yield key, value end self end |
#each {|key, value| ... } ⇒ MapWithIndifferentAccess::Map #each ⇒ Enumerator Also known as: each_pair
When a block argument is given, calls the block once for each of the target's entries, passing the entry's key and externalized value as parameters, and then returns the target object.
When no block argument is given, returns an Enumerator.
361 362 363 364 365 366 367 368 369 |
# File 'lib/map_with_indifferent_access/map.rb', line 361 def each return to_enum(:each ) unless block_given? each_key do |key| value = fetch( key ) value = Values >> value yield [key, value] end end |
#each_key ⇒ MapWithIndifferentAccess::Map
When a block argument is given, calls the block once for each of the target's keys, passing the key as a parameter, and then returns the target object.
When no block argument is given, returns an Enumerator.
380 381 382 383 384 385 386 |
# File 'lib/map_with_indifferent_access/map.rb', line 380 def each_key return to_enum(:each_key ) unless block_given? inner_map.each_key do |key| yield key end self end |
#each_value ⇒ MapWithIndifferentAccess::Map
When a block argument is given, calls the block once for each of the target's entries, passing externalization the entry value as a parameter, and then returns the target.
When no block argument is given, returns an Enumerator.
395 396 397 398 399 400 401 402 403 |
# File 'lib/map_with_indifferent_access/map.rb', line 395 def each_value return to_enum(:each_value) unless block_given? inner_map.each_value do |value| value = Values >> value yield value end self end |
#fetch(key, *more_args) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/map_with_indifferent_access/map.rb', line 196 def fetch(key, *more_args) expect_arity 1..2, key, *more_args if block_given? && !more_args.empty? warn "#{caller[ 0 ]}: warning: block supersedes default value argument" end conformed_key = conform_key( key ) value = if inner_map.key?( conformed_key ) inner_map.fetch( conformed_key ) elsif block_given? inner_map.fetch( key ) {|key| yield key } else inner_map.fetch( key, *more_args ) end Values >> value end |
#flatten ⇒ List #flatten(level) ⇒ List
Returns a new List containing one-dimensional flattening
of the target MapWithIndifferentAccess::Map. That is, for every key or value that
is an Array in the #inner_map Hash, extract its
elements into the new List.
Unlike Array#flatten or List#flatten, this method does
not flatten recursively by default. The optional level
argument determines the level of recursion to flatten.
816 817 818 |
# File 'lib/map_with_indifferent_access/map.rb', line 816 def flatten(*args) List.new( inner_map.flatten(*args) ) end |
#has_value?(value) ⇒ Boolean Also known as: value?
Returns true if the internalization of value is present
for some key in the target.
622 623 624 625 |
# File 'lib/map_with_indifferent_access/map.rb', line 622 def has_value?(value) value = Values >> value each_value.any? { |v| v == value } end |
#inject(*args, &block) ⇒ Object
7 8 9 |
# File 'lib/map_with_indifferent_access/map.rb', line 7 def inject(*args, &block) inner_map.inject(*args, &block) end |
#invert ⇒ Map
Returns a new MapWithIndifferentAccess::Map with an #inner_map Hash created by
using the the target's #inner_map's values as keys and
keys as values.
771 772 773 |
# File 'lib/map_with_indifferent_access/map.rb', line 771 def invert self.class.new( inner_map.invert ) end |
#keep_if {|key, value| ... } ⇒ Map #keep_if ⇒ Enumerator
Deletes every entry for which the block evaluates to
false, given the entry's key and externalized value.
If no block is given, then an Enumerator is returned
instead.
574 575 576 577 578 579 580 581 582 583 |
# File 'lib/map_with_indifferent_access/map.rb', line 574 def keep_if return to_enum(:keep_if ) unless block_given? inner_map.keep_if do |key, value| value = Values >> value yield key, value end self end |
#key(value) ⇒ Object?
Returns the key for an entry, the externalization of which
is equal to the externalization of value. Returns nil
if no match is found.
251 252 253 254 |
# File 'lib/map_with_indifferent_access/map.rb', line 251 def key(value) entry = rassoc( value ) entry ? entry.first : nil end |
#key?(key) ⇒ Boolean Also known as: has_key?, include?, member?
Returns true if the conformation of key is present in
the target MapWithIndifferentAccess::Map.
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/map_with_indifferent_access/map.rb', line 229 def key?(key) case key when String inner_map.key?( key ) || inner_map.key?( key.to_sym ) when Symbol inner_map.key?( key ) || inner_map.key?("#{key}") else inner_map.key?( key ) end end |
#keys ⇒ Array
Returns a new Array populated with the keys from this
MapWithIndifferentAccess::Map.
|
|
# File 'lib/map_with_indifferent_access/map.rb', line 64
|
#merge(other) ⇒ Map #merge(other) {|key, oldval, newval| ... } ⇒ Map
Returns a new MapWithIndifferentAccess::Map containing the contents of other (a
MapWithIndifferentAccess::Map, Hash, or other Hash-like object) and of the
target MapWithIndifferentAccess::Map.
Each entry in other with key that is equivalent to a key
in the target (with String/Symbol indifference) is
treated as a collision.
687 688 689 690 691 692 693 |
# File 'lib/map_with_indifferent_access/map.rb', line 687 def merge(other) if block_given? dup.merge!( other ){ |*args| yield *args } else dup.merge!( other ) end end |
#merge!(other) ⇒ Map #merge!(other) {|key, oldval, newval| ... } ⇒ Map Also known as: update
Adds the contents of other (a MapWithIndifferentAccess::Map, Hash, or other
Hash-like object) to the target MapWithIndifferentAccess::Map.
Each entry in other with key that is equivalent to a key
in the target (with String/Symbol indifference) is
treated as a collision.
728 729 730 731 732 733 734 735 736 737 738 |
# File 'lib/map_with_indifferent_access/map.rb', line 728 def merge!(other) other.each_pair do |(key, value)| key = conform_key( key ) if block_given? && inner_map.key?(key) self[key] = yield( key, self[key], value ) else self[key] = value end end self end |
#rassoc(value) ⇒ Array?
Searches through the map, comparing the externalization of
value with the externalized value of each entry using
==. Returns a 2-element array containing the key and
externalized value from the matching element or returns or
nil if no match is found.
639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/map_with_indifferent_access/map.rb', line 639 def rassoc(value) value = Values >> value entry = inner_map.detect { |(k, v)| v = Values >> v value == v } if entry entry[ 1 ] = Values >> entry[ 1 ] entry else nil end end |
#rehash ⇒ Map
Rebuilds the target's #inner_map Hash based on the
current #hash values for each key. If values of key
objects have changed since they were inserted, this will
re-index that Hash.
If #rehash is called while an iterator is traversing
the MapWithIndifferentAccess::Map or its #inner_map Hash, a RuntimeError will
be raised in the iterator.
83 84 85 86 87 |
# File 'lib/map_with_indifferent_access/map.rb', line 83 def_delegators( :inner_map, :keys, :rehash, ) |
#reject {|key| ... } ⇒ Map #reject ⇒ Enumerator
Returns a new MapWithIndifferentAccess::Map consisting of entries for which the
block returns false, given the entry's key and
externalized value.
If no block is given, then an Enumerator is returned
instead.
452 453 454 455 456 457 458 |
# File 'lib/map_with_indifferent_access/map.rb', line 452 def reject return to_enum(:reject ) unless block_given? dup.delete_if{ |key, value| yield( key, value ) } end |
#reject! {|key, value| ... } ⇒ Map? #reject! ⇒ Enumerator
Equivalent to #delete_if, but returns nil if no changes
were made.
472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/map_with_indifferent_access/map.rb', line 472 def reject! return to_enum(:reject!) unless block_given? has_rejections = false delete_if{ |key, value| is_rejected = yield( key, value ) has_rejections ||= is_rejected is_rejected } has_rejections ? self : nil end |
#replace(other) ⇒ Map
Replace the contents of the target's #inner_map Hash
with the deconstruction of the given Hash-like object.
591 592 593 594 595 |
# File 'lib/map_with_indifferent_access/map.rb', line 591 def replace(other) other_d = self.class.try_deconstruct( other ) || other inner_map.replace other_d return self end |
#select {|key| ... } ⇒ Map #select ⇒ Enumerator
Returns a new MapWithIndifferentAccess::Map consisting of entries for which the
block returns true, given the entry's key and
externalized value.
If no block is given, then an Enumerator is returned
instead.
526 527 528 529 530 531 532 |
# File 'lib/map_with_indifferent_access/map.rb', line 526 def select return to_enum(:select ) unless block_given? dup.keep_if{ |key, value| yield( key, value ) } end |
#select! {|key, value| ... } ⇒ Map? #select! ⇒ Enumerator
Equivalent to #keep_if, but returns nil if no changes
were made.
546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'lib/map_with_indifferent_access/map.rb', line 546 def select! return to_enum(:select!) unless block_given? has_rejections = false keep_if{ |key, value| is_selected = yield( key, value ) has_rejections ||= ! is_selected is_selected } has_rejections ? self : nil end |
#shift ⇒ Array, Object
Removes an entry from the target MapWithIndifferentAccess::Map and returns a 2-item
Array [ <key>, <externalized value> ] or the
externalization of the MapWithIndifferentAccess::Map's default value if it is
empty.
Yes, the behavior when the behavior for an empty MapWithIndifferentAccess::Map with
a non-nil default is weird and troublesome, but it is
parallel to the similarly weird behavior of Hash#shift.
754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/map_with_indifferent_access/map.rb', line 754 def shift if inner_map.empty? Values >> inner_map.shift else inner_result = inner_map.shift [ inner_result[ 0 ], Values >> inner_result[ 1 ] ] end end |
#to_h ⇒ Object
Alias for WrapsCollection#inner_collection. Returns the
encapsulated Hash instance.
|
|
# File 'lib/map_with_indifferent_access/map.rb', line 56
|
#to_hash ⇒ Object
11 12 13 |
# File 'lib/map_with_indifferent_access/map.rb', line 11 def to_hash inner_map.dup end |
#values ⇒ List
Returns a List containing the entry values from the target MapWithIndifferentAccess::Map.
408 409 410 |
# File 'lib/map_with_indifferent_access/map.rb', line 408 def values List.new( inner_map.values ) end |
#values_at(*keys) ⇒ List
Return a List containing the values of entries matching the given keys.
219 220 221 222 223 |
# File 'lib/map_with_indifferent_access/map.rb', line 219 def values_at(*keys) keys = keys.map{ |k| conform_key( k ) } inner_result = inner_map.values_at( *keys ) List.new( inner_result ) end |