Class: EventInventory::Base

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

Direct Known Subclasses

Catalog::Base

Defined Under Namespace

Classes: Action, Request

Class Method Summary collapse

Class Method Details

.action(operation, options = {}, &block) ⇒ Object

Creates a new operation.



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/event_inventory/base.rb', line 136

def action(operation, options={}, &block)
  options[:service] ||= service
  options[:parser] ||= self::Parser
  action = Action.new(operation, options, &block)

  self.singleton_class.class_eval do
    define_method(action.name) do |*args|
      action.execute(*args)
    end
  end
end

.get(operation, options = {}, &block) ⇒ Object

Creates a new GET operation.



126
127
128
# File 'lib/event_inventory/base.rb', line 126

def get(operation, options={}, &block)
  action(operation, options.merge(:method => :get), &block)
end

.post(operation, options = {}, &block) ⇒ Object

Creates a new POST operation.



131
132
133
# File 'lib/event_inventory/base.rb', line 131

def post(operation, options={}, &block)
  action(operation, options.merge(:method => :post), &block)
end

.service(service = nil) ⇒ Object

Sets or returns the service.



117
118
119
120
121
122
123
# File 'lib/event_inventory/base.rb', line 117

def service(service=nil)
  unless service
    read_inheritable_attribute(:service)
  else
    write_inheritable_attribute(:service, service)
  end
end