module Paginative::ModelExtension::ClassMethods
Public Instance Methods
allow_paginative_on(*mappings)
click to toggle source
Sets the paginative fields set of the class to the specified columns.
# File lib/paginative/models/model_extension.rb, line 95 def allow_paginative_on(*mappings) self.paginative_fields = process_fields(mappings) end
Private Instance Methods
process_fields(mappings)
click to toggle source
Process specified mappings to either scope to the table name of the current class or to use the mappings provided.
# File lib/paginative/models/model_extension.rb, line 103 def process_fields(mappings) result = {} mappings.each do |mapping| if mapping.is_a?(Hash) result.merge!(mapping) else result[mapping] = self_map(mapping) end end result end
self_map(field)
click to toggle source
Returns a string scoping the specified field to the current class’ table.
# File lib/paginative/models/model_extension.rb, line 118 def self_map(field) "#{self.table_name}.#{field}" end