Class: BazaModels::Ransacker

Inherits:
Object
  • Object
show all
Defined in:
lib/baza_models/ransacker.rb

Defined Under Namespace

Classes: Context, RelationshipScanner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Ransacker

Returns a new instance of Ransacker.



7
8
9
10
11
12
13
14
15
# File 'lib/baza_models/ransacker.rb', line 7

def initialize(args)
  @args = args.fetch(:args)
  @klass = args.fetch(:class)
  @db = @klass.db
  @params = args.fetch(:params)
  @_registered_params = @params # Support for SimpleFormRansack
  @query = args.fetch(:query)
  @search_key = @args[:search_key] || :q
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



5
6
7
# File 'lib/baza_models/ransacker.rb', line 5

def db
  @db
end

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/baza_models/ransacker.rb', line 5

def klass
  @klass
end

#queryObject

Returns the value of attribute query.



4
5
6
# File 'lib/baza_models/ransacker.rb', line 4

def query
  @query
end

Instance Method Details

#contextObject



22
23
24
# File 'lib/baza_models/ransacker.rb', line 22

def context
  BazaModels::Ransacker::Context.new(search_key: @search_key)
end

#resultObject



17
18
19
20
# File 'lib/baza_models/ransacker.rb', line 17

def result
  add_filters_to_query unless @add_filters_to_query_executed
  @query
end