Class: EventInventory::Base::Action

Inherits:
Object
  • Object
show all
Includes:
FormatHelper
Defined in:
lib/event_inventory/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#format_key, #format_query_value

Constructor Details

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

Returns a new instance of Action.



8
9
10
11
12
13
14
15
16
17
# File 'lib/event_inventory/base.rb', line 8

def initialize(operation, options={}, &block)
  @name = options[:as] || operation
  @operation = format_key(operation || options[:as])
  @method = options[:method]
  @service = options[:service]
  @parser = options[:parser]
  @parameters = {}

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def name
  @name
end

#operationObject (readonly)

Returns the value of attribute operation.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def operation
  @operation
end

#parametersObject (readonly)

Returns the value of attribute parameters.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def parameters
  @parameters
end

#parserObject (readonly)

Returns the value of attribute parser.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def parser
  @parser
end

#serviceObject (readonly)

Returns the value of attribute service.



6
7
8
# File 'lib/event_inventory/base.rb', line 6

def service
  @service
end

Instance Method Details

#execute(*args) ⇒ Object



24
25
26
27
# File 'lib/event_inventory/base.rb', line 24

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

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

Adds a parameter that the web service accepts.



20
21
22
# File 'lib/event_inventory/base.rb', line 20

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