Class: Awestruct::HandlerChains

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/handler_chains.rb

Constant Summary collapse

DEFAULTS =
[
  Awestruct::Handlers::CssTiltHandler::CHAIN,
  Awestruct::Handlers::RedirectHandler::CHAIN,
  Awestruct::Handlers::RestructuredtextHandler::CHAIN,
  Awestruct::Handlers::JavascriptHandler::CHAIN,
  Awestruct::Handlers::AsciidoctorHandler::CHAIN,
  Awestruct::Handlers::TiltHandler::NON_INTERPOLATION_CHAIN,
  Awestruct::Handlers::TiltHandler::INTERPOLATION_CHAIN,
  HandlerChain.new( /.*/, Awestruct::Handlers::FileHandler )
]

Instance Method Summary collapse

Constructor Details

#initialize(include_defaults = true) ⇒ HandlerChains

Returns a new instance of HandlerChains.



25
26
27
28
# File 'lib/awestruct/handler_chains.rb', line 25

def initialize(include_defaults=true)
  @chains = []
  self << :defaults if include_defaults
end

Instance Method Details

#<<(chain) ⇒ Object



34
35
36
37
# File 'lib/awestruct/handler_chains.rb', line 34

def <<(chain)
  @chains += DEFAULTS and return if ( chain == :defaults )
  @chains << chain
end

#[](path) ⇒ Object



30
31
32
# File 'lib/awestruct/handler_chains.rb', line 30

def[](path)
  @chains.detect{|e| e.matches?( path.to_s ) }
end