Module: Candy::Crunch

Included in:
CandyArray, CandyHash, Piece
Defined in:
lib/candy/crunch.rb,
lib/candy/crunch/document.rb

Overview

All of the hard crunchy bits that connect us to a collection within a Mongo database.

Defined Under Namespace

Modules: ClassMethods, Document

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



234
235
236
# File 'lib/candy/crunch.rb', line 234

def self.included(receiver)
  receiver.extend         ClassMethods
end

Instance Method Details

#collectionObject

The MongoDB collection object that everything saves to. Defaults to the class’s collection, which in turn defaults to the classname.



222
223
224
# File 'lib/candy/crunch.rb', line 222

def collection
  @__candy_collection ||= self.class.collection
end

#collection=(val) ⇒ Object

This is normally set at the class level (with a default of the classname) but you can override it on a per-object basis if you need to.



228
229
230
# File 'lib/candy/crunch.rb', line 228

def collection=(val)
  @__candy_collection = val
end