Sha256: 5718aea42a04840ca6acea9615cc6712eb53c20709b3afde50be2bfad40d4840

Contents?: true

Size: 610 Bytes

Versions: 2

Compression:

Stored size: 610 Bytes

Contents

module MongoidExt
  module DocumentExt
    extend ActiveSupport::Concern

    included do
    end

    module ClassMethods
      def find!(*args)
        find(*args) || raise(Mongoid::Errors::DocumentNotFound.new(self, args))
      end

    end

    module InstanceMethods
      def raw_save(opts = {})
        return true if !changed? && !opts.delete(:force)

        if (opts.delete(:validate) != false || valid?)
          self.collection.save(raw_attributes, opts)
          true
        else
          false
        end
      end
    end
  end
end
Mongoid::Document.send(:include, MongoidExt::DocumentExt)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid_ext-0.6.2 lib/mongoid_ext/document_ext.rb
mongoid_ext-0.6.1 lib/mongoid_ext/document_ext.rb