Class: GraphQL::Sources::ActiveRecordBase
- Inherits:
-
Dataloader::Source
- Object
- Dataloader::Source
- GraphQL::Sources::ActiveRecordBase
- Defined in:
- lib/graphql/sources/active_record_base.rb
Overview
An abstract class for interacting with active record.
Direct Known Subclasses
ActiveRecordCollection, ActiveRecordCount, ActiveRecordExists, ActiveRecordObject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model, key: :id) ⇒ ActiveRecordBase
constructor
A new instance of ActiveRecordBase.
Constructor Details
#initialize(model, key: :id) ⇒ ActiveRecordBase
Returns a new instance of ActiveRecordBase.
18 19 20 21 22 |
# File 'lib/graphql/sources/active_record_base.rb', line 18 def initialize(model, key: :id) super() @model = model @key = key end |
Class Method Details
.batch_key_for(model, key: :id) ⇒ Array
Returns a key.
10 11 12 13 14 |
# File 'lib/graphql/sources/active_record_base.rb', line 10 def self.batch_key_for(model, key: :id) return [model.to_sql, key] if model.is_a?(ActiveRecord::Relation) [model, key] end |