Module: ServiceOperation::Validations
- Defined in:
- lib/service_operation/validations.rb
Overview
Validations
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 |
# File 'lib/service_operation/validations.rb', line 6 def self.included(base) base.class_eval do extend ClassMethods end end |
Instance Method Details
#require_at_least_one_of(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/service_operation/validations.rb', line 16 def require_at_least_one_of(*args) # mothballed: # @option args.last [Boolean] :context whether to check context directly rather than send() # use if you want to prevent an auto generated value. # options = args.last.is_a?(Hash) ? args.pop : {} # base = options[:context] ? context : self base = self return if args.any? { |k| base.send(k) } errors.add(:base, "One of #{args.map(&:to_s).join(', ')} required.") end |