Class: Nuggets::JSON::MultiMixin::MULTI_OBJECT

Inherits:
Hash
  • Object
show all
Defined in:
lib/nuggets/json/multi_mixin.rb

Instance Method Summary collapse

Methods inherited from Hash

#at, #first, #in_order, #insert, #insert!, #last, #only, #only_pair, #rand

Methods included from Hash::ZipMixin

#zip, #zipkey, #zipval

Methods included from Hash::NestMixin

#array, #identity, #nest

Methods included from Hash::SeenMixin

#seen

Methods included from Hash::IDMapMixin

#idmap

Methods included from Hash::DeepMergeMixin

#deep_merge, #deep_merge!

Methods included from Hash::DeepFetchMixin

#deep_fetch

Methods included from Hash::BlankMixin

#vain?

Methods included from Hash::UnrollMixin

#unroll

Methods included from Hash::DeprocMixin

#deproc, #deproc!

Instance Method Details

#[]=(k, v) ⇒ Object



47
48
49
# File 'lib/nuggets/json/multi_mixin.rb', line 47

def []=(k, v)
  super(MULTI_KEY.new(k), v)
end

#each_multi(k) ⇒ Object



51
52
53
# File 'lib/nuggets/json/multi_mixin.rb', line 51

def each_multi(k)
  block_given? ? each { |l, v| yield v if k == l } : enum_for(__method__, k)
end

#fetch_multi(k) ⇒ Object



55
56
57
# File 'lib/nuggets/json/multi_mixin.rb', line 55

def fetch_multi(k)
  each_multi(k).to_a
end