Class: Middleman::ConfigExtension
- Defined in:
- lib/middleman-core/extension.rb
Direct Known Subclasses
Middleman::CoreExtensions::Routing, Sitemap::Extensions::Ignores, Sitemap::Extensions::Import, Sitemap::Extensions::MoveFile, Sitemap::Extensions::Proxies, Sitemap::Extensions::Redirects, Sitemap::Extensions::RequestEndpoints
Constant Summary
Constants included from Contracts
Instance Attribute Summary
Attributes inherited from Extension
Instance Method Summary collapse
- #after_configuration ⇒ Object
-
#initialize(app, config = {}, &block) ⇒ ConfigExtension
constructor
A new instance of ConfigExtension.
- #manipulate_resource_list(resources) ⇒ Object
Methods inherited from Extension
activated_extension, #add_exposed_to_context, #after_build, after_extension_activated, #after_extension_activated, #before_build, #before_configuration, clear_after_extension_callbacks, config, define_setting, expose_to_application, expose_to_config, expose_to_template, global_config, helpers, option, #ready, resources
Methods included from Contracts
Constructor Details
#initialize(app, config = {}, &block) ⇒ ConfigExtension
Returns a new instance of ConfigExtension.
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/middleman-core/extension.rb', line 491 def initialize(app, config={}, &block) @descriptors = {} @wrapped = {} self.class.exposed_to_config.each do |k, v| @descriptors[k] = [] define_singleton_method(:"__original_#{v}", &method(v)) define_singleton_method(v) do |*args, &b| @descriptors[k] << method(:"__original_#{v}").call(*args, &b) @app.sitemap.rebuild_resource_list!(:"first_run_change_#{v}") end end super end |
Instance Method Details
#after_configuration ⇒ Object
508 509 510 511 512 |
# File 'lib/middleman-core/extension.rb', line 508 def after_configuration self.class.exposed_to_config.each do |k, v| ::Middleman::CoreExtensions::Collections::StepContext.add_to_context(k, &method(:"__original_#{v}")) end end |
#manipulate_resource_list(resources) ⇒ Object
517 518 519 520 521 |
# File 'lib/middleman-core/extension.rb', line 517 def manipulate_resource_list(resources) @descriptors.values.flatten.reduce(resources) do |sum, c| c.execute_descriptor(app, sum) end end |