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.



75
76
77
78
79
80
81
82
83
# File 'lib/jsonapi/error.rb', line 75

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

#code ⇒ Object

Returns the value of attribute code.



74
75
76
# File 'lib/jsonapi/error.rb', line 74

def code
  @code
end

#detail ⇒ Object

Returns the value of attribute detail.



74
75
76
# File 'lib/jsonapi/error.rb', line 74

def detail
  @detail
end

#title ⇒ Object

Returns the value of attribute title.



74
75
76
# File 'lib/jsonapi/error.rb', line 74

def title
  @title
end

Instance Method Details

#to_hash ⇒ Object



85
86
87
88
89
# File 'lib/jsonapi/error.rb', line 85

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