Class: Vk::Schema::Definition::Response

Inherits:
Constant show all
Includes:
HasAttributes
Defined in:
lib/vk/schema/definition/response.rb

Instance Attribute Summary

Attributes inherited from Constant

#name

Attributes inherited from Vk::Schema::Definition

#definition, #name, #schema

Instance Method Summary collapse

Methods included from HasAttributes

#attributes, #properties, #required_attribute?

Methods inherited from Constant

#definition_file, #namespace, namespace_splitter, #referenced_type_name, #spec_file, #type_name

Methods inherited from Vk::Schema::Definition

#description, #to_s

Constructor Details

#initialize(name, definition, schema) ⇒ Response

Returns a new instance of Response.

Parameters:

  • name (String)
  • definition (Hash)
  • schema (Vk::Schema)

13
14
15
16
17
18
# File 'lib/vk/schema/definition/response.rb', line 13

def initialize(name, definition, schema)
  super
  @request, @name = @name.split(/_/, 2)
  @request = @request.underscore
  @name = "#{@request}_response"
end

Instance Method Details

#additional_properties?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/vk/schema/definition/response.rb', line 42

def additional_properties?
  definition['additionalProperties']
end

#parentString

Returns:

  • (String)

31
32
33
34
35
36
37
38
39
40
# File 'lib/vk/schema/definition/response.rb', line 31

def parent
  if definition['type'] == 'object'
    'Vk::Schema::Response'
  else
    reference = definition['allOf'].detect do |definition|
      definition['$ref']
    end
    schema.definition_of(reference['$ref']).referenced_type_name
  end
end

#requestString

Returns:

  • (String)

21
22
23
# File 'lib/vk/schema/definition/response.rb', line 21

def request
  @request.camelize
end

#requireString

Returns:

  • (String)

26
27
28
# File 'lib/vk/schema/definition/response.rb', line 26

def require
  "vk/api/#{@namespace}/responses/#{@name}"
end