Class: ActsAsSolr::LazyDocument
- Inherits:
-
Object
- Object
- ActsAsSolr::LazyDocument
- Defined in:
- lib/acts_as_solr/lazy_document.rb
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id, clazz) ⇒ LazyDocument
constructor
A new instance of LazyDocument.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(id, clazz) ⇒ LazyDocument
Returns a new instance of LazyDocument.
5 6 7 8 |
# File 'lib/acts_as_solr/lazy_document.rb', line 5 def initialize(id, clazz) @id = id @clazz = clazz end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/acts_as_solr/lazy_document.rb', line 10 def method_missing(name, *args) unless @__instance @__instance = @clazz.find(@id) end @__instance.send(name, *args) end |
Instance Attribute Details
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
3 4 5 |
# File 'lib/acts_as_solr/lazy_document.rb', line 3 def clazz @clazz end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/acts_as_solr/lazy_document.rb', line 3 def id @id end |