Module: Litesearch::Model

Defined in:
lib/litestack/litesearch/model.rb

Defined Under Namespace

Modules: ActiveRecordClassMethods, ActiveRecordInstanceMethods, ActiveRecordSchemaMethods, BaseClassMethods, ClassMethods, InstanceMethods, SequelClassMethods, SequelInstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/litestack/litesearch/model.rb', line 2

def self.included(klass)
  klass.include InstanceMethods
  klass.extend ClassMethods
  klass.attribute :search_rank, :float if klass.respond_to? :attribute
  if !defined?(Sequel::Model).nil? && klass.ancestors.include?(Sequel::Model)
    klass.include Litesearch::Model::SequelInstanceMethods
    klass.extend Litesearch::Model::SequelClassMethods
    Sequel::Model.extend Litesearch::Model::BaseClassMethods
  elsif !defined?(ActiveRecord::Base).nil? && klass.ancestors.include?(ActiveRecord::Base)
    klass.include Litesearch::Model::ActiveRecordInstanceMethods
    klass.extend Litesearch::Model::ActiveRecordClassMethods
    ActiveRecord::Base.extend Litesearch::Model::BaseClassMethods
    Litesearch::Schema.prepend Litesearch::Model::ActiveRecordSchemaMethods
  end
end