Class: Turbo::VisitOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo/visit/visit_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/turbo/visit/visit_options.rb', line 3

def action
  @action
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/turbo/visit/visit_options.rb', line 3

def response
  @response
end

Instance Method Details

#encodeObject

TODO Codable, JSONCodable?



24
25
26
27
28
29
30
# File 'lib/turbo/visit/visit_options.rb', line 24

def encode
  if response
    { action: @action, response: response.encode }
  else
    { action: @action }
  end
end

#initFromHash(options) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/turbo/visit/visit_options.rb', line 14

def initFromHash(options)
  raise "options is not a Hash" unless options.is_a?(Hash) # TODO remove?
  @action = options["action"] || 'advance'
  if response = options["response"]
    @response = VisitResponse.alloc.initWithStatusCode(response["statusCode"], responseHTML: response["responseHTML"])
  end
  self
end

#initWithAction(action, response: response) ⇒ Object

TODO not used for now



6
7
8
9
10
11
12
# File 'lib/turbo/visit/visit_options.rb', line 6

def initWithAction(action, response: response)
  @action = action
  if response
    @response = VisitResponse.alloc.initWithStatusCode(response["statusCode"], responseHTML: response["innerHTML"])
  end
  self
end

#inspectObject



32
33
34
# File 'lib/turbo/visit/visit_options.rb', line 32

def inspect
  "#<VisitOptions action=#{action} response=#{response}>"
end