Class: Apia::DSLs::Authenticator

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

#action(&block) ⇒ Object



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

def action(&block)
  @definition.action = block
end

#potential_error(klass, &block) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/apia/dsls/authenticator.rb', line 15

def potential_error(klass, &block)
  if block_given? && klass.is_a?(String)
    id = "#{@definition.id}/#{Helpers.camelize(klass)}"
    klass = Apia::Error.create(id, &block)
  end

  @definition.potential_errors << klass
end

#scope_validator(&block) ⇒ Object



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

def scope_validator(&block)
  unless @definition.potential_errors.include?(Apia::ScopeNotGrantedError)
    potential_error Apia::ScopeNotGrantedError
  end

  @definition.scope_validator = block
end

#type(type) ⇒ Object



11
12
13
# File 'lib/apia/dsls/authenticator.rb', line 11

def type(type)
  @definition.type = type
end