Module: Yema::Validations
- Defined in:
- lib/yema/validations.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 |
# File 'lib/yema/validations.rb', line 4 def self.included(base) super base.extend(ClassMethods) end |
Instance Method Details
#errors ⇒ Object
17 18 19 20 21 |
# File 'lib/yema/validations.rb', line 17 def errors Set.new.tap do |errors| rules.each { |rule| errors.merge(rule.errors(self)) } end end |
#rules ⇒ Object
13 14 15 |
# File 'lib/yema/validations.rb', line 13 def rules self.class.rules end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/yema/validations.rb', line 9 def valid? errors.empty? end |