Class: Focuslight::Validator::Result
- Inherits:
-
Object
- Object
- Focuslight::Validator::Result
- Defined in:
- lib/focuslight/validator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #error(param, message) ⇒ Object
- #has_error? ⇒ Boolean
- #hash ⇒ Object
-
#initialize ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
194 195 196 197 |
# File 'lib/focuslight/validator.rb', line 194 def initialize @errors = {} @params = {} end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
192 193 194 |
# File 'lib/focuslight/validator.rb', line 192 def errors @errors end |
Instance Method Details
#[](name) ⇒ Object
203 204 205 |
# File 'lib/focuslight/validator.rb', line 203 def [](name) @params[name.to_sym] end |
#[]=(name, value) ⇒ Object
207 208 209 |
# File 'lib/focuslight/validator.rb', line 207 def []=(name, value) @params[name.to_sym] = value end |
#error(param, message) ⇒ Object
211 212 213 |
# File 'lib/focuslight/validator.rb', line 211 def error(param, ) @errors[param.to_sym] = "#{param}: " + end |
#has_error? ⇒ Boolean
215 216 217 |
# File 'lib/focuslight/validator.rb', line 215 def has_error? not @errors.empty? end |
#hash ⇒ Object
199 200 201 |
# File 'lib/focuslight/validator.rb', line 199 def hash @params.dup end |