Class: TicketNetwork::Base::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/ticket_network/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, options = {}, &block) ⇒ Action

Returns a new instance of Action.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ticket_network/base.rb', line 6

def initialize(operation, options={}, &block)
  @name = options[:as] || operation
  @operation = (operation || options[:as]).to_s.camelcase.sub(/Id/, 'ID')
  @method = options[:method]
  @service = options[:service]
  @parser = options[:parser]
  @parameters = {}

  options[:defaults].each { |defaults| instance_eval(&defaults) }
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def name
  @name
end

#operationObject (readonly)

Returns the value of attribute operation.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def operation
  @operation
end

#parametersObject (readonly)

Returns the value of attribute parameters.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def parameters
  @parameters
end

#parserObject (readonly)

Returns the value of attribute parser.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def parser
  @parser
end

#serviceObject (readonly)

Returns the value of attribute service.



4
5
6
# File 'lib/ticket_network/base.rb', line 4

def service
  @service
end

Instance Method Details

#execute(*args) ⇒ Object



23
24
25
26
# File 'lib/ticket_network/base.rb', line 23

def execute(*args)
  parameters = args.first || {}
  Request.new(self, parameters).perform
end

#parameter(name, options = {}) ⇒ Object

Adds a parameter that the web service accepts.



19
20
21
# File 'lib/ticket_network/base.rb', line 19

def parameter(name, options={})
  @parameters[name] = options
end