class HQ::GraphQL::RecordLoader
Public Class Methods
new(model, column: model.primary_key, where: nil)
click to toggle source
Calls superclass method
# File lib/hq/graphql/record_loader.rb, line 6 def initialize(model, column: model.primary_key, where: nil) super() @model = model @column = column.to_s @column_type = model.type_for_attribute(@column) @where = where end
Public Instance Methods
load(key)
click to toggle source
Calls superclass method
# File lib/hq/graphql/record_loader.rb, line 14 def load(key) super(@column_type.cast(key)) end
perform(keys)
click to toggle source
# File lib/hq/graphql/record_loader.rb, line 18 def perform(keys) query(keys).each { |record| fulfill(record.public_send(@column), record) } keys.each { |key| fulfill(key, nil) unless fulfilled?(key) } end
Private Instance Methods
query(keys)
click to toggle source
# File lib/hq/graphql/record_loader.rb, line 25 def query(keys) scope = @model scope = scope.where(@where) if @where scope.where(@column => keys) end