Class: RelaxDB::View

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_name, map_func, reduce_func = nil) ⇒ View

Returns a new instance of View.



57
58
59
60
61
# File 'lib/relaxdb/views.rb', line 57

def initialize view_name, map_func, reduce_func = nil
  @view_name = view_name
  @map_func = map_func
  @reduce_func = reduce_func
end

Instance Attribute Details

#view_nameObject (readonly)

Returns the value of attribute view_name.



55
56
57
# File 'lib/relaxdb/views.rb', line 55

def view_name
  @view_name
end

Class Method Details

.design_docObject



63
64
65
# File 'lib/relaxdb/views.rb', line 63

def self.design_doc
  @design_doc ||= DesignDocument.get(RelaxDB.dd) 
end

.resetObject

A convenience for tests that create their own views



70
71
72
# File 'lib/relaxdb/views.rb', line 70

def self.reset
  @design_doc = nil
end

Instance Method Details

#add_to_design_docObject



74
75
76
77
78
# File 'lib/relaxdb/views.rb', line 74

def add_to_design_doc
  dd = View.design_doc
  dd.add_map_view(@view_name, @map_func)
  dd.add_reduce_view(@view_name, @reduce_func) if @reduce_func
end