Skip to content

Commit

Permalink
Properly handle Rollbar::LazyStore#method_missing (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojab authored Oct 15, 2020
1 parent 0fdfb22 commit 4ec049a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/rollbar/lazy_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def []=(key, value)
raw[key] = value

loaded_data.delete(key)

value
end

def data
Expand Down Expand Up @@ -76,8 +74,8 @@ def method_missing(method_sym, *args, &block)
super
end

def respond_to?(method_sym)
super || raw.respond_to?(method_sym)
def respond_to_missing?(method_sym, include_all)
raw.respond_to?(method_sym, include_all)
end
end
end
15 changes: 15 additions & 0 deletions spec/rollbar/lazy_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,19 @@
expect(new_scope.raw).to be_eql(subject.raw)
end
end

describe '#respond_to_missing?' do
it 'forwards methods existing on :raw to :raw' do
expect(subject.respond_to?(:store)).to be(true)
expect { subject.method(:store) }.not_to raise_error

expect(data).to receive(:store).with(:foo, :bar)
subject.store(:foo, :bar)
end

it 'does not have methods that do not exist on raw' do
expect(subject.respond_to?(:baz)).to be(false)
expect { subject.baz }.to raise_error(NoMethodError)
end
end
end

0 comments on commit 4ec049a

Please sign in to comment.