Class: Middleman::Sitemap::Extensions::RequestEndpoints::EndpointManager
- Inherits:
-
Object
- Object
- Middleman::Sitemap::Extensions::RequestEndpoints::EndpointManager
- Defined in:
- lib/middleman-core/sitemap/extensions/request_endpoints.rb
Overview
Manages the list of proxy configurations and manipulates the sitemap to include new resources based on those configurations
Instance Method Summary collapse
-
#create_endpoint(path, opts = {}, &block) ⇒ Object
Setup a proxy from a path to a target differs from the output path.
-
#initialize(app) ⇒ EndpointManager
constructor
A new instance of EndpointManager.
-
#manipulate_resource_list(resources)
Update the main sitemap resource list.
Constructor Details
#initialize(app) ⇒ EndpointManager
Returns a new instance of EndpointManager.
29 30 31 32 |
# File 'lib/middleman-core/sitemap/extensions/request_endpoints.rb', line 29 def initialize(app) @app = app @endpoints = {} end |
Instance Method Details
#create_endpoint(path, opts = {}, &block) ⇒ Object
Setup a proxy from a path to a target differs from the output path
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/middleman-core/sitemap/extensions/request_endpoints.rb', line 38 def create_endpoint(path, opts={}, &block) endpoint = { request_path: path } if block_given? endpoint[:output] = block else endpoint[:request_path] = opts[:path] if opts.key?(:path) end @endpoints[path] = endpoint @app.sitemap.rebuild_resource_list!(:added_endpoint) end |
#manipulate_resource_list(resources)
This method returns an undefined value.
Update the main sitemap resource list
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/middleman-core/sitemap/extensions/request_endpoints.rb', line 56 def manipulate_resource_list(resources) resources + @endpoints.map do |path, config| r = EndpointResource.new( @app.sitemap, path, config[:request_path] ) r.output = config[:output] if config.key?(:output) r end end |