Class: Apify::Exchange

Inherits:
Object
  • Object
show all
Defined in:
lib/apify/exchange.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExchange

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

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/apify/exchange.rb', line 5

def args
  @args
end

#valueObject

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

Returns:

  • (Boolean)


13
14
15
# File 'lib/apify/exchange.rb', line 13

def successful?
  not @error
end