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
Constructor Details
#initialize ⇒ Exchange
Returns a new instance of Exchange.
7 8 9 10 |
# File 'lib/apify/exchange.rb', line 7 def initialize @value = nil @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
12 13 14 15 16 17 18 19 20 |
# File 'lib/apify/exchange.rb', line 12 def respond(args, action) # hash_class = defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess @args = args.stringify_keys validate(@args, action.schema(:args), 'Invalid request args') @value = instance_eval(&action.responder) || {} @value.stringify_keys! validate(@value, action.schema(:value), 'Invalid response value') @value end |