Class: YaKassa::V3::Validators::Base
- Inherits:
-
Object
- Object
- YaKassa::V3::Validators::Base
- Defined in:
- lib/ya_kassa/v3/validators/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, params = {}) ⇒ Base
constructor
A new instance of Base.
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(name, value, params = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 7 def initialize(name, value, params = {}) @name = name @value = value @params = params @error = nil @is_validated = false end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 5 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 5 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 5 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
21 22 23 24 25 26 27 28 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 21 def valid? unless @is_validated msg = "#{self.class.name}. Need to run #validate method before call #valid?" Rails.logger.info(msg) return nil end @error.blank? end |
#validate ⇒ Object
15 16 17 18 19 |
# File 'lib/ya_kassa/v3/validators/base.rb', line 15 def validate @error = error_msg unless condition @is_validated = true nil end |