Module: RSolr::Ext::Model
- Defined in:
- lib/rsolr-ext/model.rb
Overview
include this module into a plain ruby class: class Book
include RSolr::Ext::Model
connection = RSolr::Ext.connect
default_params = {:phrase_filters=>'type:book'}
end
Then: number_10 = Book.find_by_id(10)
Defined Under Namespace
Modules: Callbacks, Findable, Pluggable
Instance Attribute Summary collapse
-
#_source ⇒ Object
readonly
The original object passed in to the #new method.
-
#solr_response ⇒ Object
readonly
Returns the value of attribute solr_response.
Class Method Summary collapse
-
.included(base) ⇒ Object
Called by Ruby Module API extends this class object.
Instance Method Summary collapse
-
#initialize(source_doc = {}, solr_response = nil) ⇒ Object
Constructor **for the class that is getting this module included** source_doc should be a hash or something similar calls each of after_initialize blocks.
-
#method_missing(m, *args, &b) ⇒ Object
the wrapper method to the @_source object.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &b) ⇒ Object
the wrapper method to the @_source object. If a method is missing, it gets sent to @_source with all of the original params and block
107 108 109 |
# File 'lib/rsolr-ext/model.rb', line 107 def method_missing(m, *args, &b) @_source.send(m, *args, &b) end |
Instance Attribute Details
#_source ⇒ Object (readonly)
The original object passed in to the #new method
91 92 93 |
# File 'lib/rsolr-ext/model.rb', line 91 def _source @_source end |
#solr_response ⇒ Object (readonly)
Returns the value of attribute solr_response.
88 89 90 |
# File 'lib/rsolr-ext/model.rb', line 88 def solr_response @solr_response end |
Class Method Details
Instance Method Details
#initialize(source_doc = {}, solr_response = nil) ⇒ Object
Constructor **for the class that is getting this module included** source_doc should be a hash or something similar calls each of after_initialize blocks
96 97 98 99 100 101 102 |
# File 'lib/rsolr-ext/model.rb', line 96 def initialize(source_doc={}, solr_response=nil) @_source = source_doc.to_mash @solr_response = solr_response self.class.hooks.each do |h| instance_eval &h end end |