module Hash::MutableWrapper(K, V)

Overview

Wraps a Hash object. The including type will behave as a hash, where objects returned by methods will be wrapped as well if the return type is the same as the original hash.

class Table
  include HashWrapper::Mutable(String, Int32)
end

table = Table.new {"a" => 1, "b" => 2}
table["a"]? # => 1
table["b"]? # => 2
table["c"]? # => nil
table["c"] = 3
table.select { |_, v| v > 2 } # => Table{"b" => 2}

table["a"] = -1
table["c"] = 3
table["a"]? # => -1
table["c"]? # => 3

table.select!("a")
table.keys # => ["a"]

Included Modules

Defined in:

views/hash_wrapper_mutable.cr

Constructors

Macro Summary

Instance methods inherited from module Hash::Wrapper(K, V)

[](*args, **options)
[](*args, **options, &)
[]
, []?(*args, **options)
[]?(*args, **options, &)
[]?
, compact(*args, **options)
compact(*args, **options, &)
compact
, dig(*args, **options)
dig(*args, **options, &)
dig
, dig?(*args, **options)
dig?(*args, **options, &)
dig?
, each(*args, **options)
each(*args, **options, &)
each
, each_key(*args, **options)
each_key(*args, **options, &)
each_key
, each_value(*args, **options)
each_value(*args, **options, &)
each_value
, empty?(*args, **options)
empty?(*args, **options, &)
empty?
, fetch(*args, **options)
fetch(*args, **options, &)
fetch
, first_key(*args, **options)
first_key(*args, **options, &)
first_key
, first_key?(*args, **options)
first_key?(*args, **options, &)
first_key?
, first_value(*args, **options)
first_value(*args, **options, &)
first_value
, first_value?(*args, **options)
first_value?(*args, **options, &)
first_value?
, has_key?(*args, **options)
has_key?(*args, **options, &)
has_key?
, has_value?(*args, **options)
has_value?(*args, **options, &)
has_value?
, inspect(io : IO) : Nil inspect, invert(*args, **options)
invert(*args, **options, &)
invert
, key_for(*args, **options)
key_for(*args, **options, &)
key_for
, key_for?(*args, **options)
key_for?(*args, **options, &)
key_for?
, keys(*args, **options)
keys(*args, **options, &)
keys
, last_key(*args, **options)
last_key(*args, **options, &)
last_key
, last_key?(*args, **options)
last_key?(*args, **options, &)
last_key?
, last_value(*args, **options)
last_value(*args, **options, &)
last_value
, last_value?(*args, **options)
last_value?(*args, **options, &)
last_value?
, merge(*args, **options)
merge(*args, **options, &)
merge
, proper_subset_of?(*args, **options)
proper_subset_of?(*args, **options, &)
proper_subset_of?
, proper_superset_of?(*args, **options)
proper_superset_of?(*args, **options, &)
proper_superset_of?
, reject(*args, **options)
reject(*args, **options, &)
reject
, select(*args, **options)
select(*args, **options, &)
select
, size(*args, **options)
size(*args, **options, &)
size
, subset_of?(*args, **options)
subset_of?(*args, **options, &)
subset_of?
, superset_of?(*args, **options)
superset_of?(*args, **options, &)
superset_of?
, to_a(*args, **options)
to_a(*args, **options, &)
to_a
, to_h : Hash(K, V) to_h, to_s(*args, **options)
to_s(*args, **options, &)
to_s
, transform_keys(*args, **options)
transform_keys(*args, **options, &)
transform_keys
, transform_values(*args, **options)
transform_values(*args, **options, &)
transform_values
, values(*args, **options)
values(*args, **options, &)
values
, values_at(*args, **options)
values_at(*args, **options, &)
values_at

Constructor methods inherited from module Hash::Wrapper(K, V)

new(wrapped : Hash(K, V) = {} of K => V) new

Instance methods inherited from module Wrapper(Hash(K, V))

==(rhs : T(K, V)) : Bool
==(rhs : self) : Bool
==
, pretty_print(*args, **options)
pretty_print(*args, **options, &)
pretty_print
, to_s(*args, **options)
to_s(*args, **options, &)
to_s
, wrapped : T(K, V) wrapped

Constructor methods inherited from module Wrapper(Hash(K, V))

new(wrapped : T(K, V) = T.new) new

Constructor Detail

def self.new(wrapped : Hash(K, V) = {} of K => V) #

[View source]

Macro Detail

macro method_missing(call) #

[View source]