Class: Recliner::View
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#reduce ⇒ Object
readonly
Returns the value of attribute reduce.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(options = {}) ⇒ View
constructor
A new instance of View.
- #invoke(database, path, *args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ View
Returns a new instance of View.
7 8 9 10 11 12 13 14 |
# File 'lib/recliner/views/view.rb', line 7 def initialize(={}) if [:map] @map = Recliner::ViewFunction::Map.new([:map]) @reduce = Recliner::ViewFunction::Reduce.new([:reduce]) if [:reduce] else @map, @reduce = Recliner::ViewGenerator.new().generate end end |
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
5 6 7 |
# File 'lib/recliner/views/view.rb', line 5 def map @map end |
#reduce ⇒ Object (readonly)
Returns the value of attribute reduce.
5 6 7 |
# File 'lib/recliner/views/view.rb', line 5 def reduce @reduce end |
Class Method Details
.from_couch(hash) ⇒ Object
16 17 18 |
# File 'lib/recliner/views/view.rb', line 16 def self.from_couch(hash) new(:map => hash['map'], :reduce => hash['reduce']) end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/recliner/views/view.rb', line 20 def ==(other) to_couch == other.to_couch end |
#invoke(database, path, *args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/recliner/views/view.rb', line 24 def invoke(database, path, *args) , = (args.) raw = fetch(database, path, args, ) if [:raw] raw else instantiate(raw['rows']) end end |