Class: Apia::DSLs::Controller

Inherits:
Apia::DSL show all
Defined in:
lib/apia/dsls/controller.rb

Instance Method Summary collapse

Methods inherited from Apia::DSL

#description, #initialize, #name, #no_schema

Constructor Details

This class inherits a constructor from Apia::DSL

Instance Method Details

#authenticator(klass = nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/apia/dsls/controller.rb', line 10

def authenticator(klass = nil, &block)
  if block_given?
    id = "#{@definition.id}/#{Helpers.camelize(klass) || 'Authenticator'}"
    klass = Apia::Authenticator.create(id, &block)
  end

  @definition.authenticator = klass
end

#endpoint(name, klass = nil, &block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/apia/dsls/controller.rb', line 19

def endpoint(name, klass = nil, &block)
  if block_given?
    id = "#{@definition.id}/#{klass || (Helpers.camelize(name) + 'Endpoint')}"
    klass = Apia::Endpoint.create(id, &block)
  end

  @definition.endpoints[name.to_sym] = klass
end

#helper(name, &block) ⇒ Object



28
29
30
# File 'lib/apia/dsls/controller.rb', line 28

def helper(name, &block)
  @definition.helpers[name] = block
end