Class: EventInventory::Base
- Inherits:
-
Object
- Object
- EventInventory::Base
- Defined in:
- lib/event_inventory/base.rb
Direct Known Subclasses
Defined Under Namespace
Class Method Summary collapse
-
.action(operation, options = {}, &block) ⇒ Object
Creates a new operation.
-
.get(operation, options = {}, &block) ⇒ Object
Creates a new GET operation.
-
.post(operation, options = {}, &block) ⇒ Object
Creates a new POST operation.
-
.service(service = nil) ⇒ Object
Sets or returns the service.
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, ={}, &block) [:service] ||= service [:parser] ||= self::Parser action = Action.new(operation, , &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, ={}, &block) action(operation, .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, ={}, &block) action(operation, .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 |