class Maini::Error

Public Class Methods

new(type, message, custom_json = nil) click to toggle source
# File lib/maini/utils/error.rb, line 6
def initialize(type, message, custom_json = nil)
  @type     = type
  @message  = I18n.t("maini.errors.#{type}", :default => message)
  @custom_json = custom_json
end

Public Instance Methods

to_json(options={}) click to toggle source
# File lib/maini/utils/error.rb, line 12
def to_json(options={})
  @obj = {:errors => { @type => [@message] }}

  if @custom_json
    @obj[:errors][@type] = [@message,@custom_json]
  end

  @obj.to_json
end