Class: Focuslight::Validator::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/focuslight/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

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

#errorsObject (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, message)
  @errors[param.to_sym] = "#{param}: " + message
end

#has_error?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/focuslight/validator.rb', line 215

def has_error?
  not @errors.empty?
end

#hashObject



199
200
201
# File 'lib/focuslight/validator.rb', line 199

def hash
  @params.dup
end