Class: SimpleRecord::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_record/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, attribute, message, options = {}) ⇒ Error

Returns a new instance of Error.



24
25
26
27
28
# File 'lib/simple_record/errors.rb', line 24

def initialize(base, attribute, message, options = {})
  self.base      = base
  self.attribute = attribute
  self.message   = message
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



22
23
24
# File 'lib/simple_record/errors.rb', line 22

def attribute
  @attribute
end

#baseObject

Returns the value of attribute base.



22
23
24
# File 'lib/simple_record/errors.rb', line 22

def base
  @base
end

#messageObject Also known as: to_s

Returns the value of attribute message.



22
23
24
# File 'lib/simple_record/errors.rb', line 22

def message
  @message
end

#optionsObject

Returns the value of attribute options.



22
23
24
# File 'lib/simple_record/errors.rb', line 22

def options
  @options
end

#typeObject

Returns the value of attribute type.



22
23
24
# File 'lib/simple_record/errors.rb', line 22

def type
  @type
end

Instance Method Details

#full_messageObject



36
37
38
# File 'lib/simple_record/errors.rb', line 36

def full_message
  attribute.to_s == 'base' ? message : generate_full_message()
end

#generate_full_message(options = {}) ⇒ Object



46
47
48
# File 'lib/simple_record/errors.rb', line 46

def generate_full_message(options = {})
    "#{attribute.to_s} #{message}"
end

#generate_message(options = {}) ⇒ Object



42
43
44
# File 'lib/simple_record/errors.rb', line 42

def generate_message(options = {})
    @message
end