Class: Tomograph::Tomogram::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/tomograph/tomogram/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, method:, content_type:, requests:, responses:, resource:) ⇒ Action

Returns a new instance of Action.



8
9
10
11
12
13
14
15
# File 'lib/tomograph/tomogram/action.rb', line 8

def initialize(path:, method:, content_type:, requests:, responses:, resource:)
  @path ||= Tomograph::Path.new(path)
  @method ||= method
  @content_type ||= content_type
  @requests ||= requests
  @responses ||= responses
  @resource ||= resource
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def content_type
  @content_type
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def path
  @path
end

#requestsObject (readonly)

Returns the value of attribute requests.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def requests
  @requests
end

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def resource
  @resource
end

#responsesObject (readonly)

Returns the value of attribute responses.



6
7
8
# File 'lib/tomograph/tomogram/action.rb', line 6

def responses
  @responses
end

Instance Method Details

#find_responses(status:) ⇒ Object



17
18
19
20
21
# File 'lib/tomograph/tomogram/action.rb', line 17

def find_responses(status:)
  to_hash['responses'].find_all do |response|
    response['status'] == status.to_s
  end
end

#to_hashObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/tomograph/tomogram/action.rb', line 23

def to_hash
  @action ||= {
    'path' => path,
    'method' => method,
    'content-type' => content_type,
    'requests' => requests,
    'responses' => responses,
    'resource' => resource
  }
end