Sha256: fcaa2476660b092fd7445e252e0e9a005552a706ae57b0ce79264ffe7fb57781
Contents?: true
Size: 890 Bytes
Versions: 3
Compression:
Stored size: 890 Bytes
Contents
require "active_support/core_ext/class/attribute" module ActiveSearch module Base def self.included(parent) parent.extend ClassMethods parent.class_attribute :search_parameters, instance_reader: false end def search_options search_parameters.last.is_a?(Hash) ? search_parameters.last : {} end def search_fields search_parameters.last.is_a?(Hash) ? search_parameters[0...-1] : search_parameters end def search_parameters if self.class.search_parameters.is_a?(Symbol) self.send(self.class.search_parameters) else self.class.search_parameters end end module ClassMethods def search_by(params, conditions = {}) after_save :reindex, conditions after_destroy :deindex, conditions self.search_parameters = params end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activesearch-0.0.11 | lib/activesearch/base.rb |
activesearch-0.0.10 | lib/activesearch/base.rb |
activesearch-0.0.9 | lib/activesearch/base.rb |