Skip to content

Commit

Permalink
Update NestedOpenStructWithHashAccess to support Ruby 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Dec 10, 2015
1 parent e7d1559 commit e66d5d0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/blacklight/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,21 @@ def merge other_hash
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
def merge! other_hash
@table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)
end
end

##
# Override #method_missing from OpenStruct to ensure the default_proc logic
# gets triggered.
def method_missing(mid, *args)
len = args.length

if len == 0
new_ostruct_member(mid)
@table[mid]
else
super
end
end

private
def set_default_proc!
Expand Down

0 comments on commit e66d5d0

Please sign in to comment.