Class: Flight::Router::Container
- Inherits:
-
Object
- Object
- Flight::Router::Container
- Defined in:
- lib/flight/router/container.rb
Defined Under Namespace
Modules: Builder
Instance Method Summary collapse
- #api(path, auth: nil, &block) ⇒ Object
- #config ⇒ Object
-
#initialize(path, app:, map:, output_dir:) ⇒ Container
constructor
A new instance of Container.
- #map ⇒ Object
- #namespace(path, auth: nil, &block) ⇒ Object
Constructor Details
#initialize(path, app:, map:, output_dir:) ⇒ Container
Returns a new instance of Container.
55 56 57 58 59 60 61 |
# File 'lib/flight/router/container.rb', line 55 def initialize(path,app:,map:,output_dir:) @path = path @app = app @map = map @output_dir = output_dir @builder = Builder.builder end |
Instance Method Details
#api(path, auth: nil, &block) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/flight/router/container.rb', line 88 def api(path,auth: nil,&block) path = @path + [path] config = {} merge_auth(config,auth) commands = parse_command path, instance_exec(&block) @config[path.join("/")] = @app .deep_merge(config) .deep_merge(commands: commands) end |
#config ⇒ Object
67 68 69 |
# File 'lib/flight/router/container.rb', line 67 def config @config ||= {} end |
#map ⇒ Object
63 64 65 |
# File 'lib/flight/router/container.rb', line 63 def map @map end |
#namespace(path, auth: nil, &block) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/flight/router/container.rb', line 71 def namespace(path,auth: nil,&block) @path << path _app = @app app = {} merge_auth(app,auth) @app = @app.dup.deep_merge(app) _config = config @config = {} instance_exec(&block) @app = _app @config = _config.merge(@config) @path.pop end |