Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Fixed
* Revert recent proxy changes which breaks proxy usage by @andrewdicken-stripe in https://github.com/NetSweet/netsuite/pull/579
* Define `respond_to?` on `RecordRef` to match `method_missing` behavior (#608)

### Breaking Changes

Expand Down
5 changes: 5 additions & 0 deletions lib/netsuite/records/record_ref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def method_missing(m, *args, &block)
end
end

def respond_to?(m, include_private = false)
return true if attributes.keys.map(&:to_sym).include?(m.to_sym)
super
end

end
end
end
8 changes: 8 additions & 0 deletions spec/netsuite/records/record_ref_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@

context 'readers' do
it 'can take on arbitrary attributes into itself on initialization' do
expect(record_ref).to respond_to(:name)
expect(record_ref).to respond_to('name')
expect(record_ref.name).to eql('This is a record_ref')

expect(record_ref).to respond_to(:banana)
expect(record_ref).to respond_to('banana')
expect(record_ref.banana).to eql('for monkeys')

expect(record_ref).to_not respond_to(:non_existant_field)
expect(record_ref).to_not respond_to('non_existant_field')
end
end
end
Expand Down