Class: JSONAPI::Serializable::ErrorSource

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, &block) ⇒ ErrorSource


11
12
13
14
15
# File 'lib/jsonapi/serializable/error.rb', line 11

def initialize(params = {}, &block)
  params.each { |k, v| instance_variable_set("@#{k}", v) }
  @_data = {}
  instance_eval(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, arg) ⇒ Object (private)


23
24
25
# File 'lib/jsonapi/serializable/error.rb', line 23

def method_missing(name, arg)
  @_data[name] = arg
end

Class Method Details

.as_jsonapi(params = {}, &block) ⇒ Object


7
8
9
# File 'lib/jsonapi/serializable/error.rb', line 7

def self.as_jsonapi(params = {}, &block)
  new(params, &block).as_jsonapi
end

Instance Method Details

#as_jsonapiObject


17
18
19
# File 'lib/jsonapi/serializable/error.rb', line 17

def as_jsonapi
  @_data
end