Module: Dao::Conducer::AutoCRUD
- Defined in:
- lib/dao/conducer/autocrud.rb
Constant Summary collapse
- Code =
proc do class << self def db @db ||= Db.instance end def db_collection db.collection(collection_name) end def all(*args) hashes = db_collection.all() hashes.map{|hash| new(hash)} end def find(*args) = args.. id = args.shift || [:id] hash = db_collection.find(id) new(hash) if hash end end def save id = self.class.db_collection.save(@attributes) @attributes.set(:id => id) true end def destroy id = self.id if id self.class.db_collection.destroy(id) @attributes.rm(:id) end id end end
Class Method Summary collapse
Class Method Details
.included(other) ⇒ Object
51 52 53 54 55 |
# File 'lib/dao/conducer/autocrud.rb', line 51 def AutoCRUD.included(other) super ensure other.module_eval(&Code) end |