Class: Apify::Exchange
- Inherits:
-
Object
- Object
- Apify::Exchange
- Defined in:
- lib/apify/exchange.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize ⇒ Exchange
constructor
A new instance of Exchange.
- #respond(args, action) ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize ⇒ Exchange
Returns a new instance of Exchange.
7 8 9 10 11 |
# File 'lib/apify/exchange.rb', line 7 def initialize @value = nil @error = false @args = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/apify/exchange.rb', line 5 def args @args end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/apify/exchange.rb', line 5 def value @value end |
Instance Method Details
#respond(args, action) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/apify/exchange.rb', line 17 def respond(args, action) logging_errors do @args = args validate(@args, action.schema(:args), 'Invalid request args') @value = instance_eval(&action.responder) || {} validate(@value, action.schema(:value), 'Invalid response value') end successful? end |
#successful? ⇒ Boolean
13 14 15 |
# File 'lib/apify/exchange.rb', line 13 def successful? not @error end |