Class: 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
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#doc ⇒ Object
Send a request for the linked document either using the “id” field’s value, or the [“value”] used for linked documents.
- #id ⇒ Object
-
#initialize(hash, model) ⇒ ViewRow
constructor
A new instance of ViewRow.
- #key ⇒ Object
- #raw_doc ⇒ Object
- #value ⇒ Object
Methods inherited from Hash
Constructor Details
#initialize(hash, model) ⇒ ViewRow
Returns a new instance of ViewRow.
486 487 488 489 |
# File 'lib/couchrest/model/designs/view.rb', line 486 def initialize(hash, model) @model = model replace(hash) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
485 486 487 |
# File 'lib/couchrest/model/designs/view.rb', line 485 def model @model end |
Instance Method Details
#doc ⇒ Object
Send a request for the linked document either using the “id” field’s value, or the [“value”] used for linked documents.
504 505 506 507 508 |
# File 'lib/couchrest/model/designs/view.rb', line 504 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 |
#id ⇒ Object
490 491 492 |
# File 'lib/couchrest/model/designs/view.rb', line 490 def id self["id"] end |
#key ⇒ Object
493 494 495 |
# File 'lib/couchrest/model/designs/view.rb', line 493 def key self["key"] end |
#raw_doc ⇒ Object
499 500 501 |
# File 'lib/couchrest/model/designs/view.rb', line 499 def raw_doc self['doc'] end |
#value ⇒ Object
496 497 498 |
# File 'lib/couchrest/model/designs/view.rb', line 496 def value self['value'] end |