Class: Fitting::Records::Spherical::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/records/spherical/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, body:, response:, title:, group:) ⇒ Request

Returns a new instance of Request.



10
11
12
13
14
15
16
17
# File 'lib/fitting/records/spherical/request.rb', line 10

def initialize(method:, path:, body:, response:, title:, group:)
  @method = method
  @path = path
  @body = body
  @response = response
  @title = title
  @group = group
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def body
  @body
end

#groupObject (readonly)

Returns the value of attribute group.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def group
  @group
end

#methodObject (readonly)

Returns the value of attribute method.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def path
  @path
end

#responseObject (readonly)

Returns the value of attribute response.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def response
  @response
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/fitting/records/spherical/request.rb', line 8

def title
  @title
end

Class Method Details

.load(hash) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/fitting/records/spherical/request.rb', line 35

def load(hash)
  new(
    method: hash['method'],
    path: hash['path'],
    body: hash['body'],
    response: Fitting::Records::Spherical::Response.load(hash['response']),
    title: hash['title'],
    group: hash['group']
  )
end

Instance Method Details

#to_hashObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/fitting/records/spherical/request.rb', line 19

def to_hash
  {
    method: method,
    path: path.to_s,
    body: body,
    response: response.to_hash,
    title: title,
    group: group
  }
end

#to_json(*_args) ⇒ Object



30
31
32
# File 'lib/fitting/records/spherical/request.rb', line 30

def to_json(*_args)
  JSON.dump(to_hash)
end