Class: CouchDB::Design::ViewsProxy

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

Overview

A proxy class for the views property.

Instance Method Summary collapse

Constructor Details

#initialize(design) ⇒ ViewsProxy

Returns a new instance of ViewsProxy.



44
45
46
47
# File 'lib/couchdb/design.rb', line 44

def initialize(design)
  @design = design
  @design["views"] = { }
end

Instance Method Details

#<<(view) ⇒ Object



49
50
51
# File 'lib/couchdb/design.rb', line 49

def <<(view)
  @design["views"].merge! view.to_hash
end

#[](name) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/couchdb/design.rb', line 53

def [](name)
  name = name.to_s
  views = @design["views"]
  return nil unless views.has_key?(name)
  map, reduce = views[name].values_at("map", "reduce")
  Design::View.new @design, name, map, reduce
end