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


31
32
33
34
35
36
37
38
39
# File 'lib/jsonapi/error.rb', line 31

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


30
31
32
# File 'lib/jsonapi/error.rb', line 30

def code
  @code
end

#detailObject

Returns the value of attribute detail


30
31
32
# File 'lib/jsonapi/error.rb', line 30

def detail
  @detail
end

#titleObject

Returns the value of attribute title


30
31
32
# File 'lib/jsonapi/error.rb', line 30

def title
  @title
end

Instance Method Details

#to_hashObject


41
42
43
44
45
# File 'lib/jsonapi/error.rb', line 41

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