Class: ConfigOMat::ConfigItem

Inherits:
Object
  • Object
show all
Defined in:
lib/config_o_mat/shared/types.rb

Defined Under Namespace

Classes: ValidationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



64
65
66
# File 'lib/config_o_mat/shared/types.rb', line 64

def errors
  @errors
end

Instance Method Details

#==(other) ⇒ Object



86
87
88
# File 'lib/config_o_mat/shared/types.rb', line 86

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
84
# File 'lib/config_o_mat/shared/types.rb', line 81

def eql?(other)
  return false if !other.is_a?(self.class)
  true
end

#error(field, message) ⇒ Object



70
71
72
73
74
# File 'lib/config_o_mat/shared/types.rb', line 70

def error(field, message)
  @errors ||= {}
  @errors[field] ||= []
  @errors[field] << message
end

#errors?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/config_o_mat/shared/types.rb', line 66

def errors?
  instance_variable_defined?(:@errors) && !(@errors.nil? || @errors.empty?)
end

#validate!Object

Raises:



76
77
78
79
# File 'lib/config_o_mat/shared/types.rb', line 76

def validate!
  validate
  raise ValidationError.new(errors) if errors?
end