Sha256: a8d6019df02b2a69caee59cac2e372b5f1d2023cc9fd41392e2779183e1dfc38
Contents?: true
Size: 1.48 KB
Versions: 25
Compression:
Stored size: 1.48 KB
Contents
module JSONAPI class Error attr_accessor :title, :detail, :id, :href, :code, :source, :links, :status, :meta def initialize(options = {}) @title = options[:title] @detail = options[:detail] @id = options[:id] @href = options[:href] @code = if JSONAPI.configuration.use_text_errors TEXT_ERRORS[options[:code]] else options[:code] end @source = options[:source] @links = options[:links] @status = Rack::Utils::SYMBOL_TO_STATUS_CODE[options[:status]].to_s @meta = options[:meta] end 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 end class Warning attr_accessor :title, :detail, :code 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 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 end end
Version data entries
25 entries across 25 versions & 1 rubygems