Class: CouchRest::Model::Designs::ViewRow
- Inherits:
-
Hash
- Object
- Hash
- CouchRest::Model::Designs::ViewRow
- Defined in:
- lib/couchrest/model/designs/view.rb
Overview
A special wrapper class that provides easy access to the key fields in a result row.
Instance Attribute Summary (collapse)
-
- (Object) model
readonly
Returns the value of attribute model.
Instance Method Summary (collapse)
-
- (Object) doc
Send a request for the linked document either using the "id" field's value, or the ["value"] used for linked documents.
- - (Object) id
-
- (ViewRow) initialize(hash, model)
constructor
A new instance of ViewRow.
- - (Object) key
- - (Object) raw_doc
- - (Object) value
Methods inherited from Hash
Constructor Details
- (ViewRow) initialize(hash, model)
A new instance of ViewRow
525 526 527 528 |
# File 'lib/couchrest/model/designs/view.rb', line 525 def initialize(hash, model) @model = model replace(hash) end |
Instance Attribute Details
- (Object) model (readonly)
Returns the value of attribute model
524 525 526 |
# File 'lib/couchrest/model/designs/view.rb', line 524 def model @model end |
Instance Method Details
- (Object) doc
Send a request for the linked document either using the "id" field's value, or the ["value"] used for linked documents.
543 544 545 546 547 |
# File 'lib/couchrest/model/designs/view.rb', line 543 def doc return model.build_from_database(self['doc']) if self['doc'] doc_id = (value.is_a?(Hash) && value['_id']) ? value['_id'] : self.id doc_id ? model.get(doc_id) : nil end |
- (Object) id
529 530 531 |
# File 'lib/couchrest/model/designs/view.rb', line 529 def id self["id"] end |
- (Object) key
532 533 534 |
# File 'lib/couchrest/model/designs/view.rb', line 532 def key self["key"] end |
- (Object) raw_doc
538 539 540 |
# File 'lib/couchrest/model/designs/view.rb', line 538 def raw_doc self['doc'] end |
- (Object) value
535 536 537 |
# File 'lib/couchrest/model/designs/view.rb', line 535 def value self['value'] end |