Class: Awestruct::HandlerChain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher, *handler_classes) ⇒ HandlerChain

Returns a new instance of HandlerChain.



8
9
10
11
# File 'lib/awestruct/handler_chain.rb', line 8

def initialize(matcher, *handler_classes)
  @matcher         = matcher
  @handler_classes = handler_classes
end

Instance Attribute Details

#handler_classesObject (readonly)

Returns the value of attribute handler_classes.



6
7
8
# File 'lib/awestruct/handler_chain.rb', line 6

def handler_classes
  @handler_classes
end

#matcherObject (readonly)

Returns the value of attribute matcher.



5
6
7
# File 'lib/awestruct/handler_chain.rb', line 5

def matcher
  @matcher
end

Instance Method Details

#create(site, path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/awestruct/handler_chain.rb', line 17

def create(site, path)
  cur = path
  @handler_classes.each do |cls|
    cur = cls.new( site, cur )
  end
  cur
end

#matches?(path) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/awestruct/handler_chain.rb', line 13

def matches?(path)
  @matcher.match( path )
end