class CouchRestAdapter::Base
Public Class Methods
all()
click to toggle source
# File lib/couch_rest_adapter.rb, line 35 def self.all query_view('all', default_design_doc) end
all_by_type()
click to toggle source
# File lib/couch_rest_adapter.rb, line 39 def self.all_by_type query_view('by_type', default_design_doc) end
find(doc_id)
click to toggle source
# File lib/couch_rest_adapter.rb, line 43 def self.find doc_id new database.get( doc_id.namespace_me(object_name) ).to_hash end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/couch_rest_adapter.rb, line 55 def self.method_missing method, *args, &block if method.to_s =~ /^find_by_(.+)$/ find_by_attribute($1, args.first, default_design_doc) else super end end
new(attributes = {})
click to toggle source
Calls superclass method
# File lib/couch_rest_adapter.rb, line 30 def initialize attributes = {} raise NotImplementedError if abstract? super attributes end
respond_to?(method)
click to toggle source
Calls superclass method
# File lib/couch_rest_adapter.rb, line 51 def self.respond_to? method (method.to_s =~ /^find_by_.*$/) ? true : super end
use_default_database()
click to toggle source
# File lib/couch_rest_adapter.rb, line 47 def self.use_default_database use_database CouchRest.database(full_path) end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/couch_rest_adapter.rb, line 75 def method_missing method, *args, &block if attribute_methods.include? method.to_s read_write method, args.first elsif method.to_s =~ /^(.+)=$/ read_write method, args.first else super end end
persisted?()
click to toggle source
# File lib/couch_rest_adapter.rb, line 85 def persisted? true end
read_attribute_for_validation(key)
click to toggle source
# File lib/couch_rest_adapter.rb, line 89 def read_attribute_for_validation(key) self[key.to_s] end
save(bulk = false)
click to toggle source
Calls superclass method
# File lib/couch_rest_adapter.rb, line 63 def save bulk = false return false if invalid? return false unless run_callbacks(:save) _set_id_and_namespace super bulk end
save!(bulk = false)
click to toggle source
# File lib/couch_rest_adapter.rb, line 70 def save! bulk = false raise CouchRestAdapter::InvalidDocument if invalid? save bulk end
Protected Instance Methods
abstract?()
click to toggle source
# File lib/couch_rest_adapter.rb, line 94 def abstract? self.class.to_s == 'CouchRestAdapter::Base' end