Class: ActiveCouch::RawView
- Inherits:
-
Object
- Object
- ActiveCouch::RawView
- Defined in:
- lib/active_couch/views/raw_view.rb
Class Attribute Summary collapse
-
.database ⇒ Object
readonly
Returns the value of attribute database.
Class Method Summary collapse
- .for_database(database) ⇒ Object
- .map(map_function) ⇒ Object
- .name ⇒ Object
- .reduce(reduce_function) ⇒ Object
- .to_json(existing_view = {}) ⇒ Object
Class Attribute Details
.database ⇒ Object (readonly)
Returns the value of attribute database.
9 10 11 |
# File 'lib/active_couch/views/raw_view.rb', line 9 def database @database end |
Class Method Details
.for_database(database) ⇒ Object
19 20 21 |
# File 'lib/active_couch/views/raw_view.rb', line 19 def for_database(database) @database = database end |
.map(map_function) ⇒ Object
11 12 13 |
# File 'lib/active_couch/views/raw_view.rb', line 11 def map(map_function) @map_function = map_function end |
.name ⇒ Object
34 35 36 |
# File 'lib/active_couch/views/raw_view.rb', line 34 def name "#{self}".underscore end |
.reduce(reduce_function) ⇒ Object
15 16 17 |
# File 'lib/active_couch/views/raw_view.rb', line 15 def reduce(reduce_function) @reduce_function = reduce_function end |
.to_json(existing_view = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_couch/views/raw_view.rb', line 23 def to_json(existing_view = {}) results_hash = { '_id' => "_design/#{name}", 'language' => 'javascript' } results_hash.merge!(existing_view) results_hash['views'] = { "#{name}" => { 'map' => @map_function } } results_hash['views']["#{name}"]['reduce'] = @reduce_function unless @reduce_function.nil? # Convert to JSON results_hash.to_json end |