Class: GRApiManager::RouteGroup
- Inherits:
-
Object
- Object
- GRApiManager::RouteGroup
- Defined in:
- lib/gr_api_manager.rb
Overview
RouteGroup — provides nested route grouping with shared prefixes and options.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#group(sub_prefix = '', sub_options = {}, &block) ⇒ Object
Nested sub-grouping.
-
#initialize(server, prefix = '', options = {}) ⇒ RouteGroup
constructor
A new instance of RouteGroup.
Constructor Details
#initialize(server, prefix = '', options = {}) ⇒ RouteGroup
Returns a new instance of RouteGroup.
489 490 491 492 493 |
# File 'lib/gr_api_manager.rb', line 489 def initialize(server, prefix = '', = {}) @server = server @prefix = prefix.to_s @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
487 488 489 |
# File 'lib/gr_api_manager.rb', line 487 def @options end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
487 488 489 |
# File 'lib/gr_api_manager.rb', line 487 def prefix @prefix end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
487 488 489 |
# File 'lib/gr_api_manager.rb', line 487 def server @server end |
Instance Method Details
#group(sub_prefix = '', sub_options = {}, &block) ⇒ Object
Nested sub-grouping.
510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/gr_api_manager.rb', line 510 def group(sub_prefix = '', = {}, &block) combined_prefix = File.join('/', @prefix, sub_prefix.to_s).gsub(%r{/+}, '/') = @options.merge() if @options[:requires] && [:requires] [:requires] = merge_requires(@options[:requires], [:requires]) end sub_group = RouteGroup.new(@server, combined_prefix, ) block.call(sub_group) if block sub_group end |