class CacheQL::RecordLoader
Public Class Methods
new(model, column: model.primary_key, where: nil)
click to toggle source
# File lib/cacheql/record_loader.rb, line 5 def initialize(model, column: model.primary_key, where: nil) @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/cacheql/record_loader.rb, line 12 def load(key) super(@column_type.cast(key)) end
perform(keys)
click to toggle source
# File lib/cacheql/record_loader.rb, line 16 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/cacheql/record_loader.rb, line 23 def query(keys) scope = @model scope = scope.where(@where) if @where scope.where(@column => keys) end