Class: Croesus::Base
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#validations ⇒ Object
Returns the value of attribute validations.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash, validations) ⇒ Base
constructor
A new instance of Base.
- #valid? ⇒ Boolean
Constructor Details
#initialize(hash, validations) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 |
# File 'lib/croesus/validations.rb', line 24 def initialize(hash, validations) self.errors = {} self.hash = hash self.validations = validations.inject({ }){ |memo,(k,v)| memo[k] = v.to_s.downcase; memo } validate end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
22 23 24 |
# File 'lib/croesus/validations.rb', line 22 def errors @errors end |
#hash ⇒ Object
Returns the value of attribute hash.
22 23 24 |
# File 'lib/croesus/validations.rb', line 22 def hash @hash end |
#validations ⇒ Object
Returns the value of attribute validations.
22 23 24 |
# File 'lib/croesus/validations.rb', line 22 def validations @validations end |
Class Method Details
.validate(hash, validations) ⇒ Object
36 37 38 |
# File 'lib/croesus/validations.rb', line 36 def self.validate(hash, validations) new(hash, validations) end |
Instance Method Details
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/croesus/validations.rb', line 32 def valid? errors.empty? end |