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.



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

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.



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

def handler_classes
  @handler_classes
end

#matcherObject (readonly)

Returns the value of attribute matcher.



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

def matcher
  @matcher
end

Instance Method Details

#create(site, path) ⇒ Object



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

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

#matches?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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