Sha256: 58cb95d1fb91979d4065f47292649895f8b7bf2dfe21158e2df3719a6a774ad8
Contents?: true
Size: 838 Bytes
Versions: 1
Compression:
Stored size: 838 Bytes
Contents
module Remarkable module MongoMapper module Matchers class ValidatePresenceOfMatcher < Remarkable::MongoMapper::Base #:nodoc: arguments :collection => :keys, :as => :key collection_assertions :allow_nil? protected def allow_nil? @subject.send("#{@key}=", nil) !@subject.valid? && !@subject.errors.on(@key).blank? 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.0.1 | lib/remarkable_mongomapper/matchers/validate_presence_of_matcher.rb |