Sha256: d1c1bf53c23a6b2d05750196488df8946a1aac7ef5403451ae8e855b149c3ece

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

module Remarkable
  module MongoMapper
    module Matchers
      class ValidatePresenceOfMatcher < Remarkable::MongoMapper::Base
        
        arguments :collection => :attributes, :as => :attribute
        optional  :message

        collection_assertions :allow_nil?
        default_options :message => "can't be empty"

        protected

          def allow_nil?
            bad?(nil, :message)
          end

      end
      
      # Ensures that the model cannot be saved if one of the attributes listed is not present.
      #
      #
      # == Examples
      #
      #   should_validate_presence_of :name, :phone_number
      #   it { should validate_presence_of(:name, :phone_number) }
      #
      def validate_presence_of(*args, &block)
        ValidatePresenceOfMatcher.new(*args, &block).spec(self)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yeastymobs-remarkable_mongomapper-0.1.0 lib/remarkable_mongomapper/matchers/validate_presence_of_matcher.rb