Sha256: 6439a6e0b1713794e52f8ca21055e3ce36a4e3c1ebc446d2bf8a80b65f7a4f52
Contents?: true
Size: 865 Bytes
Versions: 1
Compression:
Stored size: 865 Bytes
Contents
module MeteorMotion module Collections class MotionModel < MeteorMotion::Collection def initialize klass, aka="" # if !(klass < ::MeteorMotion::Adapters::MotionModel) # raise 'Adapter not compatible with collection' # end @klass = klass name = aka == "" ? klass.to_s.downcase : aka super name end def add id, fields obj = find(id) puts "ADDING: #{obj}" if obj obj.save({local: true}) else obj = @klass.new({id: id}.merge(fields)) obj.save({local: true}) end super end def update id, fields, cleared obj = find(id) obj.attributes = fields obj.save({local: true}) super end def remove id obj = find(id) if obj obj.destroy({local: true}) end super end def find id obj = @klass.where(:id).eq(id).first end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
meteor-motion-0.1.0 | motion/collections/motion_model.rb |