Class: Apia::Definitions::API
- Inherits:
- 
      Apia::Definition
      
        - Object
- Apia::Definition
- Apia::Definitions::API
 
- Defined in:
- lib/apia/definitions/api.rb
Instance Attribute Summary collapse
- 
  
    
      #authenticator  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute authenticator. 
- 
  
    
      #controllers  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute controllers. 
- 
  
    
      #exception_handlers  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute exception_handlers. 
- 
  
    
      #route_set  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute route_set. 
- 
  
    
      #scopes  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute scopes. 
Attributes inherited from Apia::Definition
#description, #id, #name, #schema
Instance Method Summary collapse
- #dsl ⇒ Object
- #setup ⇒ Object
- 
  
    
      #validate(errors)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    Validate the API to ensure that everything within is acceptable for use. 
Methods inherited from Apia::Definition
Constructor Details
This class inherits a constructor from Apia::Definition
Instance Attribute Details
#authenticator ⇒ Object
Returns the value of attribute authenticator.
| 12 13 14 | # File 'lib/apia/definitions/api.rb', line 12 def authenticator @authenticator end | 
#controllers ⇒ Object (readonly)
Returns the value of attribute controllers.
| 13 14 15 | # File 'lib/apia/definitions/api.rb', line 13 def controllers @controllers end | 
#exception_handlers ⇒ Object (readonly)
Returns the value of attribute exception_handlers.
| 15 16 17 | # File 'lib/apia/definitions/api.rb', line 15 def exception_handlers @exception_handlers end | 
#route_set ⇒ Object (readonly)
Returns the value of attribute route_set.
| 14 15 16 | # File 'lib/apia/definitions/api.rb', line 14 def route_set @route_set end | 
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
| 16 17 18 | # File 'lib/apia/definitions/api.rb', line 16 def scopes @scopes end | 
Instance Method Details
#dsl ⇒ Object
| 25 26 27 | # File 'lib/apia/definitions/api.rb', line 25 def dsl @dsl ||= DSLs::API.new(self) end | 
#setup ⇒ Object
| 18 19 20 21 22 23 | # File 'lib/apia/definitions/api.rb', line 18 def setup @route_set = RouteSet.new @controllers = {} @exception_handlers = HookSet.new @scopes = {} end | 
#validate(errors) ⇒ void
This method returns an undefined value.
Validate the API to ensure that everything within is acceptable for use
| 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # File 'lib/apia/definitions/api.rb', line 33 def validate(errors) if @authenticator && !(@authenticator.respond_to?(:ancestors) && @authenticator.ancestors.include?(Apia::Authenticator)) errors.add self, 'InvalidAuthenticator', 'The authenticator must be a class that inherits from Apia::Authenticator' end @controllers.each do |name, controller| unless name.to_s =~ /\A[\w-]+\z/i errors.add self, 'InvalidControllerName', "The controller name #{name} is invalid. It can only contain letters, numbers, underscores, and hyphens" end unless controller.respond_to?(:ancestors) && controller.ancestors.include?(Apia::Controller) errors.add self, 'InvalidController', "The controller for #{name} must be a class that inherits from Apia::Controller" end end end |