Class: ActsAsSolr::LazyDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/lazy_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, clazz) ⇒ LazyDocument

Returns a new instance of LazyDocument.



5
6
7
8
# File 'lib/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/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

#clazzObject (readonly)

Returns the value of attribute clazz.



3
4
5
# File 'lib/lazy_document.rb', line 3

def clazz
  @clazz
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/lazy_document.rb', line 3

def id
  @id
end