Class: Relax::Service
- Inherits:
-
Object
- Object
- Relax::Service
- Extended by:
- Contextable
- Defined in:
- lib/relax/service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #authenticate(*args) ⇒ Object
-
#initialize(values = {}) ⇒ Service
constructor
A new instance of Service.
Methods included from Contextable
context, defaults, extend_context
Constructor Details
#initialize(values = {}) ⇒ Service
Returns a new instance of Service.
3 4 5 |
# File 'lib/relax/service.rb', line 3 def initialize(values={}) @values = values end |
Class Method Details
.endpoint(url, options = {}, &block) ⇒ Object
15 16 17 |
# File 'lib/relax/service.rb', line 15 def endpoint(url, ={}, &block) Endpoint.new(self, url, , &block) end |
.register_action(action) ⇒ Object
:nodoc:
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/relax/service.rb', line 19 def register_action(action) # :nodoc: @actions ||= {} unless @actions[action.name] @actions[action.name] = action.name define_method(action.name) do |*args| action.execute(@values, @credentials, *args) end else raise ArgumentError.new("Duplicate action '#{action.name}'.") end end |
Instance Method Details
#authenticate(*args) ⇒ Object
7 8 9 10 |
# File 'lib/relax/service.rb', line 7 def authenticate(*args) @credentials = args self end |