Class: RelaxDB::ViewByDelegator

Inherits:
Delegator
  • Object
show all
Defined in:
lib/relaxdb/view_by_delegator.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_name, opts) ⇒ ViewByDelegator

Returns a new instance of ViewByDelegator.



5
6
7
8
9
# File 'lib/relaxdb/view_by_delegator.rb', line 5

def initialize(view_name, opts)
  super([])
  @view_name = view_name
  @opts = opts
end

Instance Method Details

#__getobj__Object



11
12
13
14
15
16
17
# File 'lib/relaxdb/view_by_delegator.rb', line 11

def __getobj__
  unless @ids
    @opts[:raw] = true
    @ids = RelaxDB.doc_ids @view_name, @opts
  end
  @ids
end

#__setobj__(obj) ⇒ Object



19
20
21
# File 'lib/relaxdb/view_by_delegator.rb', line 19

def __setobj__ obj
  # Intentionally empty
end

#load!Object



23
24
25
26
27
28
29
30
# File 'lib/relaxdb/view_by_delegator.rb', line 23

def load!
  if @ids
    RelaxDB.load! @ids
  else
    @opts[:include_docs] = true
    RelaxDB.docs @view_name, @opts
  end
end