Class: Apia::DSLs::API

Inherits:
Apia::DSL show all
Defined in:
lib/apia/dsls/api.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



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

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

#exception_handler(block_var = nil, &block) ⇒ Object



20
21
22
# File 'lib/apia/dsls/api.rb', line 20

def exception_handler(block_var = nil, &block)
  @definition.exception_handlers.add(block_var, &block)
end

#routes(&block) ⇒ Object



24
25
26
# File 'lib/apia/dsls/api.rb', line 24

def routes(&block)
  @definition.route_set.dsl.instance_eval(&block) if block_given?
end

#scopes(&block) ⇒ Object



28
29
30
31
32
33
# File 'lib/apia/dsls/api.rb', line 28

def scopes(&block)
  return unless block_given?

  dsl = DSLs::ScopeDescriptions.new(@definition)
  dsl.instance_eval(&block)
end