Class: ApiBomb::Fighter
- Inherits:
-
Object
- Object
- ApiBomb::Fighter
- Includes:
- Celluloid
- Defined in:
- lib/api_bomb/fighter.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #fire ⇒ Object
-
#initialize(paths: nil, base_url: nil, options: {}) ⇒ Fighter
constructor
A new instance of Fighter.
Constructor Details
#initialize(paths: nil, base_url: nil, options: {}) ⇒ Fighter
Returns a new instance of Fighter.
6 7 8 9 10 |
# File 'lib/api_bomb/fighter.rb', line 6 def initialize(paths: nil, base_url: nil, options: {}) @base_url = base_url @options = @paths = paths end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/api_bomb/fighter.rb', line 4 def base_url @base_url end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/api_bomb/fighter.rb', line 4 def @options end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
4 5 6 |
# File 'lib/api_bomb/fighter.rb', line 4 def paths @paths end |
Instance Method Details
#fire ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/api_bomb/fighter.rb', line 12 def fire route = @paths.pick url = URI::join(base_url, route.path) response = nil hold_time = Benchmark.measure do response = HTTP.send( route.action, url, ApiBomb::LambdaHash.hasharize(.merge(route.)) ) end return OpenStruct.new(response: response, hold_time: hold_time.real) end |