Class: Orchestrate::Application
- Inherits:
-
Object
- Object
- Orchestrate::Application
- Defined in:
- lib/orchestrate/application.rb
Overview
Applications in Orchestrate are the highest level of your project.
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The API key provided.
-
#client ⇒ Orchestrate::Client
readonly
The client tied to this application.
-
#host ⇒ String
readonly
The Orchestrate data center URL.
Instance Method Summary collapse
-
#[](collection_name) ⇒ Object
Accessor for Collections.
-
#in_parallel {|accumulator| ... } ⇒ Object
Performs requests in parallel.
-
#initialize(client_or_api_key, host = "https://api.orchestrate.io") {|connection| ... } ⇒ Object
constructor
Instantiate a new Application.
-
#inside_parallel? ⇒ true, false
is the Application currently inside a block from
#in_parallel?
?. -
#perform(api_method, *args) ⇒ Object
Perform a request against the client.
-
#to_s ⇒ Object
(also: #inspect)
A pretty-printed representation of the application.
Constructor Details
#initialize(client_or_api_key, host = "https://api.orchestrate.io") {|connection| ... } ⇒ Object
Instantiate a new Application
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/orchestrate/application.rb', line 19 def initialize(client_or_api_key, host="https://api.orchestrate.io", &client_setup) if client_or_api_key.kind_of?(Orchestrate::Client) @client = client_or_api_key @api_key = client.api_key @host = client.host else @api_key = client_or_api_key @host = host @client = Client.new(api_key, host, &client_setup) end client.ping end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns The API key provided.
7 8 9 |
# File 'lib/orchestrate/application.rb', line 7 def api_key @api_key end |
#client ⇒ Orchestrate::Client (readonly)
Returns The client tied to this application.
13 14 15 |
# File 'lib/orchestrate/application.rb', line 13 def client @client end |
#host ⇒ String (readonly)
Returns The Orchestrate data center URL.
10 11 12 |
# File 'lib/orchestrate/application.rb', line 10 def host @host end |
Instance Method Details
#[](collection_name) ⇒ Object
Accessor for Collections
35 36 37 |
# File 'lib/orchestrate/application.rb', line 35 def [](collection_name) Collection.new(self, collection_name) end |
#in_parallel {|accumulator| ... } ⇒ Object
This method is not Thread-safe. Requests generated from the same
application instance in different threads while #in_parallel is running
will behave unpredictably. Use #dup
to create per-thread application
instances.
Performs requests in parallel. Requires using a Faraday adapter that supports parallel requests.
52 53 54 55 56 57 |
# File 'lib/orchestrate/application.rb', line 52 def in_parallel(&block) @inside_parallel = true results = client.in_parallel(&block) @inside_parallel = nil results end |
#inside_parallel? ⇒ true, false
is the Application currently inside a block from #in_parallel?
?
61 62 63 |
# File 'lib/orchestrate/application.rb', line 61 def inside_parallel? !! @inside_parallel end |
#perform(api_method, *args) ⇒ Object
Perform a request against the client.
69 70 71 |
# File 'lib/orchestrate/application.rb', line 69 def perform(api_method, *args) client.send(api_method, *args) end |
#to_s ⇒ Object Also known as: inspect
Returns a pretty-printed representation of the application.
74 75 76 |
# File 'lib/orchestrate/application.rb', line 74 def to_s "#<Orchestrate::Application api_key=#{api_key[0..7]}...>" end |