Class: JSONAPI::Warning

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Warning

Returns a new instance of Warning.



58
59
60
61
62
63
64
65
66
# File 'lib/jsonapi/error.rb', line 58

def initialize(options = {})
  @title          = options[:title]
  @detail         = options[:detail]
  @code           = if JSONAPI.configuration.use_text_errors
                      TEXT_ERRORS[options[:code]]
                    else
                      options[:code]
                    end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



57
58
59
# File 'lib/jsonapi/error.rb', line 57

def code
  @code
end

#detailObject

Returns the value of attribute detail.



57
58
59
# File 'lib/jsonapi/error.rb', line 57

def detail
  @detail
end

#titleObject

Returns the value of attribute title.



57
58
59
# File 'lib/jsonapi/error.rb', line 57

def title
  @title
end

Instance Method Details

#to_hashObject



68
69
70
71
72
# File 'lib/jsonapi/error.rb', line 68

def to_hash
  hash = {}
  instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) unless instance_variable_get(var).nil? }
  hash
end