Class: HttpStub::Configurer::Command
- Inherits:
-
Object
- Object
- HttpStub::Configurer::Command
- Defined in:
- lib/http_stub/configurer/command.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ Command
constructor
A new instance of Command.
- #resetable? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Command
Returns a new instance of Command.
6 7 8 9 10 11 12 |
# File 'lib/http_stub/configurer/command.rb', line 6 def initialize() @host = [:host] @port = [:port] @request = [:request] @description = [:description] @resetable_flag = !![:resetable] end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 |
# File 'lib/http_stub/configurer/command.rb', line 14 def execute response = Net::HTTP.start(@host, @port) { |http| http.request(@request) } raise "Error occurred #{@description}: #{response.message}" unless response.code == "200" end |
#resetable? ⇒ Boolean
19 20 21 |
# File 'lib/http_stub/configurer/command.rb', line 19 def resetable? @resetable_flag end |