module ServiceOperation::Validations
Public Class Methods
included(base)
click to toggle source
# File lib/service_operation/validations.rb, line 6 def self.included(base) base.class_eval do extend ClassMethods end end
Public Instance Methods
require_at_least_one_of(*args)
click to toggle source
# 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