Skip to content

Commit

Permalink
ends_with? => end_with?
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 26, 2021
1 parent ba2649a commit ea9b61f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/blacklight/nested_open_struct_with_hash_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def merge! other_hash
def method_missing(mid, *args, **kwargs, &block)
len = args.length

res = if mid.to_s.ends_with?('!')
res = if mid.to_s.end_with?('!')
m = mid[0...-1]
new_ostruct_member!(m)
@table[m]
elsif mid.to_s.ends_with?('=')
elsif mid.to_s.end_with?('=')
m = mid[0...-1]
new_ostruct_member!(m)
@table[m] = args.first
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@
expect(subject.blah).to have_attributes(key: :blah)
end
end

describe 'adding new parameters' do
subject { described_class.new(Blacklight::Configuration::Field) }

it 'strips the trailing !' do
subject.blaH!
expect(subject.blah).to have_attributes(key: :blah)
end

it 'supports direct assignment' do
subject.blah = '123'
expect(subject.blah).to eq '123'
end
end
end

0 comments on commit ea9b61f

Please sign in to comment.