Class: CouchDB::Design::ViewsProxy
- Inherits:
-
Object
- Object
- CouchDB::Design::ViewsProxy
- Defined in:
- lib/couchdb/design.rb
Overview
A proxy class for the views property.
Instance Method Summary collapse
- #<<(view) ⇒ Object
- #[](name) ⇒ Object
-
#initialize(design) ⇒ ViewsProxy
constructor
A new instance of ViewsProxy.
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 |