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(hash_like = nil, **keys, &blk) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/with_ease/open_struct/hash_api.rb', line 19

def update(hash_like=nil, **keys, &blk)
  if blk
    return _update_with_blk(hash_like, **keys, &blk)
  end

  if hash_like
    _update(hash_like.to_h.merge(**keys))
  else
    _update(keys)
  end
end