Sha256: f76f5dc512f8d0d868c0d445532f18408c4622796317103a216b1eb5e9c88483

Contents?: true

Size: 506 Bytes

Versions: 60

Compression:

Stored size: 506 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Safe
      module ClassMethods
        def inherited(subclass)
          super
          subclass.safe if safe?
        end

        def safe
          @safe = true
        end

        def safe?
          @safe == true
        end
      end

      module InstanceMethods
        def save_to_collection(options={})
          options[:safe] = self.class.safe? unless options.key?(:safe)
          super
        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 7 rubygems

Version Path
mongo_mapper-unstable-2010.07.15 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.14 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.13 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.12 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.09 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.08 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.07 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.06 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.05 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.02 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.07.01 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.30 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.29 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.28 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.25 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.24 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-unstable-2010.06.23 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.8.2 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.8.1 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.8.0 lib/mongo_mapper/plugins/safe.rb