Class: DataloaderRelationProxy::Record
- Inherits:
-
Object
- Object
- DataloaderRelationProxy::Record
- Defined in:
- lib/dataloader_relation_proxy/record.rb
Overview
Wraps ActiveRecord records and provides accessors for loading relationships via GraphQL::Dataloader
Instance Method Summary collapse
-
#==(other) ⇒ Object
Allows comparison with other wrappers or their underlying objects.
-
#initialize(object, dataloader) ⇒ Record
constructor
A new instance of Record.
- #is_a?(thing) ⇒ Boolean
- #loaded? ⇒ Boolean
Constructor Details
#initialize(object, dataloader) ⇒ Record
Returns a new instance of Record.
9 10 11 12 |
# File 'lib/dataloader_relation_proxy/record.rb', line 9 def initialize(object, dataloader) @object = object @dataloader = dataloader end |
Instance Method Details
#==(other) ⇒ Object
Allows comparison with other wrappers or their underlying objects
17 18 19 20 21 22 23 24 25 |
# File 'lib/dataloader_relation_proxy/record.rb', line 17 def ==(other) if other.is_a?(DataloaderRelationProxy::Record) comparator = other.instance_variable_get(:@object) else comparator = other end @object.send(:==, comparator) end |
#is_a?(thing) ⇒ Boolean
27 28 29 |
# File 'lib/dataloader_relation_proxy/record.rb', line 27 def is_a?(thing) super || @object.send(:is_a?, thing) end |
#loaded? ⇒ Boolean
31 32 33 |
# File 'lib/dataloader_relation_proxy/record.rb', line 31 def loaded? true end |