Class: Burner::Modeling::Validations::Base
- Inherits:
-
Object
- Object
- Burner::Modeling::Validations::Base
- Defined in:
- lib/burner/modeling/validations/base.rb
Overview
Common logic shared among all Validation subclasses. This class is an abstract class, make sure to implement:
-
#valid?(object, resolver)
-
#default_message
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key:, message: '') ⇒ Base
constructor
A new instance of Base.
- #message ⇒ Object
Constructor Details
#initialize(key:, message: '') ⇒ Base
Returns a new instance of Base.
22 23 24 25 26 27 |
# File 'lib/burner/modeling/validations/base.rb', line 22 def initialize(key:, message: '') raise ArgumentError, 'key is required' if key.to_s.empty? @key = key.to_s @message = .to_s end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
20 21 22 |
# File 'lib/burner/modeling/validations/base.rb', line 20 def key @key end |
Instance Method Details
#message ⇒ Object
29 30 31 |
# File 'lib/burner/modeling/validations/base.rb', line 29 def @message.to_s.empty? ? "#{key} #{}" : @message.to_s end |