Class: BazaModels::Ransacker
- Inherits:
-
Object
- Object
- BazaModels::Ransacker
- Defined in:
- lib/baza_models/ransacker.rb
Defined Under Namespace
Classes: Context, RelationshipScanner
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #context ⇒ Object
-
#initialize(args) ⇒ Ransacker
constructor
A new instance of Ransacker.
- #result ⇒ Object
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
#db ⇒ Object (readonly)
Returns the value of attribute db.
5 6 7 |
# File 'lib/baza_models/ransacker.rb', line 5 def db @db end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/baza_models/ransacker.rb', line 5 def klass @klass end |
#query ⇒ Object
Returns the value of attribute query.
4 5 6 |
# File 'lib/baza_models/ransacker.rb', line 4 def query @query end |
Instance Method Details
#context ⇒ Object
22 23 24 |
# File 'lib/baza_models/ransacker.rb', line 22 def context BazaModels::Ransacker::Context.new(search_key: @search_key) end |
#result ⇒ Object
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 |