Module: SimplyStored::Couch
- Defined in:
- lib/simply_stored/couch.rb,
lib/simply_stored/couch/find_by.rb,
lib/simply_stored/couch/finders.rb,
lib/simply_stored/couch/has_one.rb,
lib/simply_stored/couch/has_many.rb,
lib/simply_stored/couch/belongs_to.rb,
lib/simply_stored/couch/properties.rb,
lib/simply_stored/couch/validations.rb,
lib/simply_stored/couch/association_property.rb,
lib/simply_stored/couch/has_and_belongs_to_many.rb,
lib/simply_stored/couch/views/deleted_model_view_spec.rb,
lib/simply_stored/couch/views/array_property_view_spec.rb
Defined Under Namespace
Modules: BelongsTo, ClassMethods, FindBy, Finders, HasAndBelongsToMany, HasMany, HasOne, Properties, Validations, Views
Classes: AssociationProperty
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.compact_all_design_documents(database) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/simply_stored/couch.rb', line 158
def self.compact_all_design_documents(database)
db = CouchRest.database(database)
db.info design_docs = CouchRest.get("#{database}/_all_docs?startkey=%22_design%22&endkey=%22_design0%22")['rows'].map do |row|
[row['id'], row['value']['rev']]
end
design_docs.each do |doc_id, rev|
puts "#{database}/_compact/#{doc_id.gsub("_design/",'')}"
CouchRest.post("#{database}/_compact/#{doc_id.gsub("_design/",'')}")
end
design_docs.size
end
|
.delete_all_design_documents(database) ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/simply_stored/couch.rb', line 146
def self.delete_all_design_documents(database)
db = CouchRest.database(database)
db.info design_docs = CouchRest.get("#{database}/_all_docs?startkey=%22_design%22&endkey=%22_design0%22")['rows'].map do |row|
[row['id'], row['value']['rev']]
end
design_docs.each do |doc_id, rev|
db.delete_doc({'_id' => doc_id, '_rev' => rev})
end
design_docs.size
end
|
.included(clazz) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/simply_stored/couch.rb', line 26
def self.included(clazz)
clazz.class_eval do
include CouchPotato::Persistence
include InstanceMethods
extend ClassMethods
end
clazz.instance_eval do
attr_accessor :_accessible_attributes, :_protected_attributes
view :all_documents, :key => :created_at
end
end
|
Instance Method Details
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/simply_stored/couch.rb', line 130
def (local_options = nil)
forced_reload = false
with_deleted = false
limit = nil
descending = false
if local_options
local_options.assert_valid_keys(:force_reload, :with_deleted, :limit, :order)
forced_reload = local_options.delete(:force_reload)
with_deleted = local_options[:with_deleted]
limit = local_options[:limit]
descending = (local_options[:order] == :desc) ? true : false
end
return [forced_reload, with_deleted, limit, descending]
end
|