Class: TicketNetwork::Base
- Inherits:
-
Object
- Object
- TicketNetwork::Base
- Defined in:
- lib/ticket_network/base.rb
Direct Known Subclasses
Defined Under Namespace
Class Method Summary collapse
-
.action(operation, options = {}, &block) ⇒ Object
Creates a new operation.
-
.defaults(&block) ⇒ Object
Sets or returns action defaults.
-
.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.
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ticket_network/base.rb', line 139 def action(operation, ={}, &block) [:service] ||= service [:defaults] ||= defaults [: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 |
.defaults(&block) ⇒ Object
Sets or returns action defaults.
120 121 122 123 124 125 126 |
# File 'lib/ticket_network/base.rb', line 120 def defaults(&block) unless block read_inheritable_attribute(:defaults) else write_inheritable_array(:defaults, [block]) end end |
.get(operation, options = {}, &block) ⇒ Object
Creates a new GET operation.
129 130 131 |
# File 'lib/ticket_network/base.rb', line 129 def get(operation, ={}, &block) action(operation, .merge(:method => :get), &block) end |
.post(operation, options = {}, &block) ⇒ Object
Creates a new POST operation.
134 135 136 |
# File 'lib/ticket_network/base.rb', line 134 def post(operation, ={}, &block) action(operation, .merge(:method => :post), &block) end |
.service(service = nil) ⇒ Object
Sets or returns the service.
111 112 113 114 115 116 117 |
# File 'lib/ticket_network/base.rb', line 111 def service(service=nil) unless service read_inheritable_attribute(:service) else write_inheritable_attribute(:service, service) end end |