Class: SimpleJsonapi::Definition::Error

Inherits:
Base
  • Object
show all
Includes:
Concerns::HasLinksObject, Concerns::HasMetaObject
Defined in:
lib/simple_jsonapi/definition/error.rb

Instance Attribute Summary collapse

Attributes included from Concerns::HasMetaObject

#meta_definitions

Attributes included from Concerns::HasLinksObject

#link_definitions

Instance Method Summary collapse

Methods included from Concerns::HasMetaObject

#meta

Methods included from Concerns::HasLinksObject

#link

Constructor Details

#initializeError

Returns a new instance of Error.



11
12
13
14
15
# File 'lib/simple_jsonapi/definition/error.rb', line 11

def initialize
  super
  @member_definitions = {}
  @source_definition = SimpleJsonapi::Definition::ErrorSource.new
end

Instance Attribute Details

#member_definitionsHash{Symbol => Attribute} (readonly)

Returns:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/simple_jsonapi/definition/error.rb', line 5

class SimpleJsonapi::Definition::Error < SimpleJsonapi::Definition::Base
  include SimpleJsonapi::Definition::Concerns::HasLinksObject
  include SimpleJsonapi::Definition::Concerns::HasMetaObject

  attr_reader :member_definitions, :source_definition

  def initialize
    super
    @member_definitions = {}
    @source_definition = SimpleJsonapi::Definition::ErrorSource.new
  end

  private def initialize_dup(new_def)
    super
    new_def.instance_variable_set(:@source_definition, @source_definition.dup) unless @source_definition.nil?
    new_def.instance_variable_set(:@member_definitions, @member_definitions.dup) unless @member_definitions.nil?
  end

  # @overload id(options = {}, &block)
  # @overload id(value, options = {})
  # @return [void]
  def id(*args, **options, &block)
    member_definitions[:id] = SimpleJsonapi::Definition::Attribute.new(:id, *args, **options, &block)
  end

  # @overload status(options = {}, &block)
  # @overload status(value, options = {})
  # @return [void]
  def status(*args, **options, &block)
    member_definitions[:status] = SimpleJsonapi::Definition::Attribute.new(:status, *args, **options, &block)
  end

  # @overload code(options = {}, &block)
  # @overload code(value, options = {})
  # @return [void]
  def code(*args, **options, &block)
    member_definitions[:code] = SimpleJsonapi::Definition::Attribute.new(:code, *args, **options, &block)
  end

  # @overload title(options = {}, &block)
  # @overload title(value, options = {})
  # @return [void]
  def title(*args, **options, &block)
    member_definitions[:title] = SimpleJsonapi::Definition::Attribute.new(:title, *args, **options, &block)
  end

  # @overload detail(options = {}, &block)
  # @overload detail(value, options = {})
  # @return [void]
  def detail(*args, **options, &block)
    member_definitions[:detail] = SimpleJsonapi::Definition::Attribute.new(:detail, *args, **options, &block)
  end

  # @overload about_link(options = {}, &block)
  # @overload about_link(value, options = {})
  # @return [void]
  def about_link(*args, **options, &block)
    link(:about, *args, options, &block)
  end

  # @see ErrorSource#initialize
  # @return [void]
  def source(&block)
    @source_definition = SimpleJsonapi::Definition::ErrorSource.new(&block)
  end
end

#source_definitionErrorSource (readonly)

Returns:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/simple_jsonapi/definition/error.rb', line 5

class SimpleJsonapi::Definition::Error < SimpleJsonapi::Definition::Base
  include SimpleJsonapi::Definition::Concerns::HasLinksObject
  include SimpleJsonapi::Definition::Concerns::HasMetaObject

  attr_reader :member_definitions, :source_definition

  def initialize
    super
    @member_definitions = {}
    @source_definition = SimpleJsonapi::Definition::ErrorSource.new
  end

  private def initialize_dup(new_def)
    super
    new_def.instance_variable_set(:@source_definition, @source_definition.dup) unless @source_definition.nil?
    new_def.instance_variable_set(:@member_definitions, @member_definitions.dup) unless @member_definitions.nil?
  end

  # @overload id(options = {}, &block)
  # @overload id(value, options = {})
  # @return [void]
  def id(*args, **options, &block)
    member_definitions[:id] = SimpleJsonapi::Definition::Attribute.new(:id, *args, **options, &block)
  end

  # @overload status(options = {}, &block)
  # @overload status(value, options = {})
  # @return [void]
  def status(*args, **options, &block)
    member_definitions[:status] = SimpleJsonapi::Definition::Attribute.new(:status, *args, **options, &block)
  end

  # @overload code(options = {}, &block)
  # @overload code(value, options = {})
  # @return [void]
  def code(*args, **options, &block)
    member_definitions[:code] = SimpleJsonapi::Definition::Attribute.new(:code, *args, **options, &block)
  end

  # @overload title(options = {}, &block)
  # @overload title(value, options = {})
  # @return [void]
  def title(*args, **options, &block)
    member_definitions[:title] = SimpleJsonapi::Definition::Attribute.new(:title, *args, **options, &block)
  end

  # @overload detail(options = {}, &block)
  # @overload detail(value, options = {})
  # @return [void]
  def detail(*args, **options, &block)
    member_definitions[:detail] = SimpleJsonapi::Definition::Attribute.new(:detail, *args, **options, &block)
  end

  # @overload about_link(options = {}, &block)
  # @overload about_link(value, options = {})
  # @return [void]
  def about_link(*args, **options, &block)
    link(:about, *args, options, &block)
  end

  # @see ErrorSource#initialize
  # @return [void]
  def source(&block)
    @source_definition = SimpleJsonapi::Definition::ErrorSource.new(&block)
  end
end

Instance Method Details

This method returns an undefined value.



61
62
63
# File 'lib/simple_jsonapi/definition/error.rb', line 61

def about_link(*args, **options, &block)
  link(:about, *args, options, &block)
end

#code(options = {}, &block) ⇒ void #code(value, options = {}) ⇒ void

This method returns an undefined value.



40
41
42
# File 'lib/simple_jsonapi/definition/error.rb', line 40

def code(*args, **options, &block)
  member_definitions[:code] = SimpleJsonapi::Definition::Attribute.new(:code, *args, **options, &block)
end

#detail(options = {}, &block) ⇒ void #detail(value, options = {}) ⇒ void

This method returns an undefined value.



54
55
56
# File 'lib/simple_jsonapi/definition/error.rb', line 54

def detail(*args, **options, &block)
  member_definitions[:detail] = SimpleJsonapi::Definition::Attribute.new(:detail, *args, **options, &block)
end

#id(options = {}, &block) ⇒ void #id(value, options = {}) ⇒ void

This method returns an undefined value.



26
27
28
# File 'lib/simple_jsonapi/definition/error.rb', line 26

def id(*args, **options, &block)
  member_definitions[:id] = SimpleJsonapi::Definition::Attribute.new(:id, *args, **options, &block)
end

#source(&block) ⇒ void

This method returns an undefined value.



67
68
69
# File 'lib/simple_jsonapi/definition/error.rb', line 67

def source(&block)
  @source_definition = SimpleJsonapi::Definition::ErrorSource.new(&block)
end

#status(options = {}, &block) ⇒ void #status(value, options = {}) ⇒ void

This method returns an undefined value.



33
34
35
# File 'lib/simple_jsonapi/definition/error.rb', line 33

def status(*args, **options, &block)
  member_definitions[:status] = SimpleJsonapi::Definition::Attribute.new(:status, *args, **options, &block)
end

#title(options = {}, &block) ⇒ void #title(value, options = {}) ⇒ void

This method returns an undefined value.



47
48
49
# File 'lib/simple_jsonapi/definition/error.rb', line 47

def title(*args, **options, &block)
  member_definitions[:title] = SimpleJsonapi::Definition::Attribute.new(:title, *args, **options, &block)
end