Sha256: fffc639ca37e3293dbaafe87b69ad1aa802393c52b42f142f6bd560a229668e1
Contents?: true
Size: 511 Bytes
Versions: 10
Compression:
Stored size: 511 Bytes
Contents
module Hybag class Validator include ActiveModel::Validations validate :bag_valid validate :require_persisted attr_reader :bag def initialize(bag) @bag = bag end def validate! unless self.valid? raise "Invalid Object for bagging" end end def bag_valid errors.add(:bag, "is not valid for bagging.") unless bag.baggable? end def require_persisted errors.add(:bag, "is not persisted.") unless bag.persisted? end end end
Version data entries
10 entries across 10 versions & 1 rubygems