Class: Maini::Error
- Inherits:
-
Object
- Object
- Maini::Error
- Defined in:
- lib/maini/utils/error.rb
Instance Method Summary collapse
-
#initialize(type, message, custom_json = nil) ⇒ Error
constructor
A new instance of Error.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(type, message, custom_json = nil) ⇒ Error
Returns a new instance of Error.
6 7 8 9 10 |
# File 'lib/maini/utils/error.rb', line 6 def initialize(type, , custom_json = nil) @type = type = I18n.t("maini.errors.#{type}", :default => ) @custom_json = custom_json end |
Instance Method Details
#to_json(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/maini/utils/error.rb', line 12 def to_json(={}) @obj = {:errors => { @type => [] }} if @custom_json @obj[:errors][@type] = [,@custom_json] end @obj.to_json end |