Module: WithEase::OpenStruct::HashApi
- Included in:
- OpenStruct
- Defined in:
- lib/with_ease/open_struct/hash_api.rb
Instance Method Summary collapse
Instance Method Details
#merge(hash_like = nil, **keys, &blk) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/with_ease/open_struct/hash_api.rb', line 7 def merge(hash_like=nil, **keys, &blk) if blk return _merge_with_blk(hash_like, **keys, &blk) end if hash_like _merge(hash_like.to_h.merge(**keys)) else _merge(keys) end end |
#update(*positionals, **keys, &blk) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/with_ease/open_struct/hash_api.rb', line 19 def update(*positionals, **keys, &blk) if blk return _update_with_blk(*positionals, **keys, &blk) end case positionals in [] _update(keys) in [hash_like] _update(hash_like.to_h.merge(**keys)) else raise ArgumentError, "must not provide more than one postional argument" end end |