Sha256: 6d64479b3db21b7f968ba5e04ccf263fdcb0f7c489c1c3e0b67a80ded1a8893a

Contents?: true

Size: 630 Bytes

Versions: 6

Compression:

Stored size: 630 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Safe
      extend ActiveSupport::Concern

      module ClassMethods
        attr_reader :safe_options

        def inherited(subclass)
          super
          subclass.safe(safe_options) if safe?
        end

        def safe(options = true)
          @safe_options = options
        end

        def safe?
          @safe_options ||= nil
          !!@safe_options
        end
      end

      def save_to_collection(options={})
        options[:safe] = self.class.safe_options if !options.key?(:safe) && self.class.safe?
        super
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongo_mapper-0.14.0 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.14.0.rc1 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/plugins/safe.rb
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/plugins/safe.rb