Class: Restflow::Sequence
- Inherits:
-
Object
- Object
- Restflow::Sequence
- Defined in:
- lib/restflow/sequence.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Instance Method Summary collapse
- #base_url(url) ⇒ Object
- #delete(path, data = nil) ⇒ Object
- #get(path) ⇒ Object
- #html ⇒ Object
-
#initialize(execution_dir, description, base_url = nil, &block) ⇒ Sequence
constructor
A new instance of Sequence.
- #json ⇒ Object
- #post(path, data) ⇒ Object
- #put(path, data) ⇒ Object
- #response ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(execution_dir, description, base_url = nil, &block) ⇒ Sequence
Returns a new instance of Sequence.
27 28 29 30 31 32 33 34 |
# File 'lib/restflow/sequence.rb', line 27 def initialize(execution_dir, description, base_url = nil, &block) @responses = [] @execution_dir = execution_dir @base_url = base_url if base_url @description = description raise "Sequence block is empty!!" unless block instance_eval &block end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
25 26 27 |
# File 'lib/restflow/sequence.rb', line 25 def description @description end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
25 26 27 |
# File 'lib/restflow/sequence.rb', line 25 def responses @responses end |
Instance Method Details
#base_url(url) ⇒ Object
36 37 38 |
# File 'lib/restflow/sequence.rb', line 36 def base_url(url) @base_url = url end |
#delete(path, data = nil) ⇒ Object
52 53 54 55 56 |
# File 'lib/restflow/sequence.rb', line 52 def delete(path, data = nil) @response = send_post_data(:delete, path, data) @responses << @response @response end |
#get(path) ⇒ Object
40 41 42 43 44 |
# File 'lib/restflow/sequence.rb', line 40 def get(path) @response = HTTParty.get("#{@base_url}/#{path}") @responses << @response @response end |
#html ⇒ Object
68 69 70 |
# File 'lib/restflow/sequence.rb', line 68 def html Nokogiri::HTML(@response.body) end |
#json ⇒ Object
72 73 74 |
# File 'lib/restflow/sequence.rb', line 72 def json JSON.parse(@response.body) if @response.body end |
#post(path, data) ⇒ Object
46 47 48 49 50 |
# File 'lib/restflow/sequence.rb', line 46 def post(path, data) @response = send_post_data(:post, path, data) @responses << @response @response end |
#put(path, data) ⇒ Object
58 59 60 61 62 |
# File 'lib/restflow/sequence.rb', line 58 def put(path, data) @response = send_post_data(:put, path, data) @responses << @response @response end |
#response ⇒ Object
64 65 66 |
# File 'lib/restflow/sequence.rb', line 64 def response @response.body end |
#status ⇒ Object
76 77 78 |
# File 'lib/restflow/sequence.rb', line 76 def status @response.code end |