Module: Lycra::Search::ClassMethods
- Defined in:
- lib/lycra/search.rb
Instance Method Summary collapse
- #fields(*fields) ⇒ Object
- #inherited(base) ⇒ Object
- #method_missing(meth, *args, &block) ⇒ Object
- #models(*models) ⇒ Object
- #respond_to_missing?(meth, include_private = false) ⇒ Boolean
- #search(term = nil, query: nil, filter: nil, post_filter: nil, sort: nil, models: nil, fields: nil, aggregations: nil, &block) ⇒ Object
- #singleton ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
150 151 152 153 |
# File 'lib/lycra/search.rb', line 150 def method_missing(meth, *args, &block) return search.send(meth, *args, &block) if singleton.respond_to?(meth) super end |
Instance Method Details
#fields(*fields) ⇒ Object
159 160 161 162 |
# File 'lib/lycra/search.rb', line 159 def fields(*fields) @fields = fields unless fields.empty? @fields ||= [] end |
#inherited(base) ⇒ Object
136 137 138 139 140 |
# File 'lib/lycra/search.rb', line 136 def inherited(base) # Make sure we inherit the parent's class-level instance variables whenever we inherit from the class. base.send :instance_variable_set, :@models, models.try(:dup) base.send :instance_variable_set, :@fields, fields.try(:dup) end |
#models(*models) ⇒ Object
164 165 166 167 |
# File 'lib/lycra/search.rb', line 164 def models(*models) @models = models unless models.empty? @models ||= [] end |
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
155 156 157 |
# File 'lib/lycra/search.rb', line 155 def respond_to_missing?(meth, include_private=false) singleton.respond_to?(meth, include_private) || super end |
#search(term = nil, query: nil, filter: nil, post_filter: nil, sort: nil, models: nil, fields: nil, aggregations: nil, &block) ⇒ Object
142 143 144 |
# File 'lib/lycra/search.rb', line 142 def search(term=nil, query: nil, filter: nil, post_filter: nil, sort: nil, models: nil, fields: nil, aggregations: nil, &block) new(term, query: query, filter: filter, post_filter: post_filter, sort: sort, models: models, fields: fields, aggregations: aggregations, &block) end |
#singleton ⇒ Object
146 147 148 |
# File 'lib/lycra/search.rb', line 146 def singleton @singleton ||= search end |