Class: Apia::Definitions::Controller
- Inherits:
-
Apia::Definition
- Object
- Apia::Definition
- Apia::Definitions::Controller
- Defined in:
- lib/apia/definitions/controller.rb
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
Returns the value of attribute authenticator.
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#helpers ⇒ Object
readonly
Returns the value of attribute helpers.
Attributes inherited from Apia::Definition
#description, #id, #name, #schema
Instance Method Summary collapse
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.
10 11 12 |
# File 'lib/apia/definitions/controller.rb', line 10 def authenticator @authenticator end |
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
11 12 13 |
# File 'lib/apia/definitions/controller.rb', line 11 def endpoints @endpoints end |
#helpers ⇒ Object (readonly)
Returns the value of attribute helpers.
12 13 14 |
# File 'lib/apia/definitions/controller.rb', line 12 def helpers @helpers end |
Instance Method Details
#dsl ⇒ Object
19 20 21 |
# File 'lib/apia/definitions/controller.rb', line 19 def dsl @dsl ||= DSLs::Controller.new(self) end |
#setup ⇒ Object
14 15 16 17 |
# File 'lib/apia/definitions/controller.rb', line 14 def setup @endpoints = {} @helpers = {} end |
#validate(errors) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/apia/definitions/controller.rb', line 23 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 @endpoints.each do |name, endpoint| unless name.to_s =~ /\A[\w-]+\z/i errors.add self, 'InvalidEndpointName', "The endpoint name #{name} is invalid. It can only contain letters, numbers, underscores, and hyphens" end unless endpoint.respond_to?(:ancestors) && endpoint.ancestors.include?(Apia::Endpoint) errors.add self, 'InvalidEndpoint', "The endpoint for #{name} must be a class that inherits from Apia::Endpoint" end end end |