Class: CouchRest::Model::Designs::DesignMapper
- Inherits:
-
Object
- Object
- CouchRest::Model::Designs::DesignMapper
- Defined in:
- lib/couchrest/model/designs.rb
Overview
Map method calls defined in a design block to actions in the Design Document.
Instance Attribute Summary (collapse)
-
- (Object) design_doc
Temporary variable storing the design doc.
-
- (Object) method
Basic mapper attributes.
-
- (Object) model
Basic mapper attributes.
-
- (Object) prefix
Basic mapper attributes.
Instance Method Summary (collapse)
- - (Object) disable_auto_update
- - (Object) enable_auto_update
-
- (Object) filter(name, function)
Really simple design function that allows a filter to be added.
-
- (DesignMapper) initialize(model, prefix = nil)
constructor
A new instance of DesignMapper.
-
- (Object) model_type_key
Convenience wrapper to access model's type key option.
-
- (Object) view(name, opts = {})
Add the specified view to the design doc the definition was made in and create quick access methods in the model.
Constructor Details
- (DesignMapper) initialize(model, prefix = nil)
A new instance of DesignMapper
83 84 85 86 87 88 89 90 |
# File 'lib/couchrest/model/designs.rb', line 83 def initialize(model, prefix = nil) self.model = model self.prefix = prefix self.method = Design.method_name(prefix) create_model_design_doc_reader self.design_doc = model.send(method) || assign_model_design_doc end |
Instance Attribute Details
- (Object) design_doc
Temporary variable storing the design doc
81 82 83 |
# File 'lib/couchrest/model/designs.rb', line 81 def design_doc @design_doc end |
- (Object) method
Basic mapper attributes
78 79 80 |
# File 'lib/couchrest/model/designs.rb', line 78 def method @method end |
- (Object) model
Basic mapper attributes
78 79 80 |
# File 'lib/couchrest/model/designs.rb', line 78 def model @model end |
- (Object) prefix
Basic mapper attributes
78 79 80 |
# File 'lib/couchrest/model/designs.rb', line 78 def prefix @prefix end |
Instance Method Details
- (Object) disable_auto_update
92 93 94 |
# File 'lib/couchrest/model/designs.rb', line 92 def disable_auto_update design_doc.auto_update = false end |
- (Object) enable_auto_update
96 97 98 |
# File 'lib/couchrest/model/designs.rb', line 96 def enable_auto_update design_doc.auto_update = true end |
- (Object) filter(name, function)
Really simple design function that allows a filter to be added. Filters are simple functions used when listening to the _changes feed.
No methods are created here, the design is simply updated. See the CouchDB API for more information on how to use this.
112 113 114 |
# File 'lib/couchrest/model/designs.rb', line 112 def filter(name, function) design_doc.create_filter(name, function) end |
- (Object) model_type_key
Convenience wrapper to access model's type key option.
117 118 119 |
# File 'lib/couchrest/model/designs.rb', line 117 def model_type_key model.model_type_key end |
- (Object) view(name, opts = {})
Add the specified view to the design doc the definition was made in and create quick access methods in the model.
102 103 104 |
# File 'lib/couchrest/model/designs.rb', line 102 def view(name, opts = {}) design_doc.create_view(name, opts) end |