Module: Rumonade::HashExtensions::InstanceMethods

Defined in:
lib/rumonade/hash.rb

Constant Summary collapse

METHODS_TO_REPLACE_WITH_MONAD =

Preserve native map and flatten methods for compatibility

Monad::DEFAULT_METHODS_TO_REPLACE_WITH_MONAD - [:map, :flatten]

Instance Method Summary collapse

Instance Method Details

#bind(lam = nil, &blk) ⇒ Object



21
22
23
# File 'lib/rumonade/hash.rb', line 21

def bind(lam = nil, &blk)
  inject(self.class.empty) { |hsh, elt| hsh.merge((lam || blk).call(elt)) }
end

#get(key) ⇒ Option

Returns a Some containing the value associated with key, or None if not present.

Returns:

  • (Option)

    a Some containing the value associated with key, or None if not present



26
27
28
# File 'lib/rumonade/hash.rb', line 26

def get(key)
  Option(self[key])
end