Class: Zodra::ApiDefinition
- Inherits:
-
Object
- Object
- Zodra::ApiDefinition
- Defined in:
- lib/zodra/api_definition.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #add_resource(resource) ⇒ Object
- #controller_namespace ⇒ Object
-
#initialize(base_path:) ⇒ ApiDefinition
constructor
A new instance of ApiDefinition.
- #namespaces ⇒ Object
Constructor Details
#initialize(base_path:) ⇒ ApiDefinition
Returns a new instance of ApiDefinition.
7 8 9 10 |
# File 'lib/zodra/api_definition.rb', line 7 def initialize(base_path:) @base_path = base_path @resources = [] end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
5 6 7 |
# File 'lib/zodra/api_definition.rb', line 5 def base_path @base_path end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
5 6 7 |
# File 'lib/zodra/api_definition.rb', line 5 def resources @resources end |
Instance Method Details
#add_resource(resource) ⇒ Object
12 13 14 |
# File 'lib/zodra/api_definition.rb', line 12 def add_resource(resource) @resources << resource end |
#controller_namespace ⇒ Object
20 21 22 |
# File 'lib/zodra/api_definition.rb', line 20 def controller_namespace namespaces.join('/') end |
#namespaces ⇒ Object
16 17 18 |
# File 'lib/zodra/api_definition.rb', line 16 def namespaces @base_path.split('/').reject(&:empty?).map(&:to_sym) end |