Module: ActsAsExplorable::Element
- Included in:
- Base
- Defined in:
- lib/acts_as_explorable/element.rb,
lib/acts_as_explorable/element/in.rb,
lib/acts_as_explorable/element/base.rb,
lib/acts_as_explorable/element/sort.rb,
lib/acts_as_explorable/element/dynamic_filter.rb
Defined Under Namespace
Classes: Base, DynamicFilter, In, Sort
Instance Attribute Summary collapse
-
#full_query ⇒ Object
Returns the value of attribute full_query.
-
#model ⇒ Object
Returns the value of attribute model.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#query_parts ⇒ Object
Returns the value of attribute query_parts.
-
#query_string ⇒ Object
Returns the value of attribute query_string.
-
#query_type ⇒ Object
Returns the value of attribute query_type.
Class Method Summary collapse
-
.build(type, query, model) ⇒ ActsAsExplorable::Element
This method acts as a factory to build a concrete element.
Instance Method Summary collapse
- #after_init ⇒ Object
- #execute(query_object) ⇒ Object
- #initialize(query, model, element_type = nil) ⇒ Object
Instance Attribute Details
#full_query ⇒ Object
Returns the value of attribute full_query.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def full_query @full_query end |
#model ⇒ Object
Returns the value of attribute model.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def model @model end |
#parameters ⇒ Object
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def parameters @parameters end |
#query_parts ⇒ Object
Returns the value of attribute query_parts.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def query_parts @query_parts end |
#query_string ⇒ Object
Returns the value of attribute query_string.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def query_string @query_string end |
#query_type ⇒ Object
Returns the value of attribute query_type.
8 9 10 |
# File 'lib/acts_as_explorable/element.rb', line 8 def query_type @query_type end |
Class Method Details
.build(type, query, model) ⇒ ActsAsExplorable::Element
This method acts as a factory to build a concrete element
22 23 24 25 26 27 |
# File 'lib/acts_as_explorable/element.rb', line 22 def self.build(type, query, model) klass = Module.nesting.last.const_get('Element').const_get(type.to_s.camelize) instance = klass.new(query, model, type) rescue NameError DynamicFilter.new(query, model, type) end |
Instance Method Details
#after_init ⇒ Object
42 |
# File 'lib/acts_as_explorable/element.rb', line 42 def after_init; end |
#execute(query_object) ⇒ Object
44 45 46 |
# File 'lib/acts_as_explorable/element.rb', line 44 def execute(query_object) query_object.send(@query_type, @full_query) end |
#initialize(query, model, element_type = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/acts_as_explorable/element.rb', line 29 def initialize(query, model, element_type = nil) query = query.to_acts_as_explorable(ActsAsExplorable.filters.keys) @type = element_type if element_type @model = model @query_string = query[:values] @query_parts = [] filter_parameters(query[:params]) after_init render if @parameters.present? end |