class ROM::CouchDB::Dataset
Attributes
results[R]
Public Class Methods
new(data, options = {})
click to toggle source
Calls superclass method
# File lib/rom/couchdb/dataset.rb, line 18 def initialize(data, options = {}) @data = data super end
row_proc()
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 61 def self.row_proc TransprocFunctions[:symbolize_keys] end
Public Instance Methods
count()
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 39 def count @data.count end
delete(object)
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 33 def delete(object) input = stringify_proc.call(object.dup) @connection.delete_doc(input) self end
find_by_id(id, params = {})
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 47 def find_by_id(id, params = {}) document = @connection.get(id, params).to_hash self.class.new([document], connection: @connection) end
find_by_view(name, params = {})
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 52 def find_by_view(name, params = {}) results = @connection.view(name, params) self.class.new([results], connection: @connection) end
insert(object)
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 23 def insert(object) input = stringify_proc.call(object.dup) resp = @connection.save_doc(input) # send back the id and revision of the document object[:_id] = resp['id'] object[:_rev] = resp['rev'] self end
Also aliased as: <<
stringify_proc()
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 57 def stringify_proc TransprocFunctions[:stringify_keys] end
to_a()
click to toggle source
# File lib/rom/couchdb/dataset.rb, line 43 def to_a @data end