Module: ElasticRecord::Searching
- Defined in:
- lib/elastic_record/searching.rb
Instance Method Summary collapse
-
#current_elastic_search ⇒ Object
:nodoc:.
-
#current_elastic_search=(relation) ⇒ Object
:nodoc:.
- #elastic_scope(name, body, &block) ⇒ Object
- #elastic_search ⇒ Object
Instance Method Details
#current_elastic_search ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/elastic_record/searching.rb', line 22 def current_elastic_search #:nodoc: Thread.current["#{self}_current_elastic_search"] end |
#current_elastic_search=(relation) ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/elastic_record/searching.rb', line 26 def current_elastic_search=(relation) #:nodoc: Thread.current["#{self}_current_elastic_search"] = relation end |
#elastic_scope(name, body, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/elastic_record/searching.rb', line 11 def elastic_scope(name, body, &block) extension = Module.new(&block) if block singleton_class.send(:define_method, name) do |*args| relation = body.call(*args) relation = elastic_search.merge(relation) extension ? relation.extending(extension) : relation end end |
#elastic_search ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/elastic_record/searching.rb', line 3 def elastic_search if current_elastic_search current_elastic_search.clone else elastic_relation end end |