Module: Angelo::Mustermann

Defined in:
lib/angelo/mustermann.rb

Defined Under Namespace

Modules: ClassMethods Classes: RouteMap

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

hrm, sneaky



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/angelo/mustermann.rb', line 9

def self.included base
  base.extend ClassMethods
  base.class_eval do
    def_delegator :@responder, :mustermann
  end

  [Responder, Responder::Websocket, Responder::Eventsource].each do |res|
    res.class_eval do
      attr_accessor :mustermann
    end
  end
end

Instance Method Details

#filter(which) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/angelo/mustermann.rb', line 61

def filter which
  fs = self.class.filters[which][:default].dup
  self.class.filters[which].each do |pattern, f|
    if ::Mustermann === pattern and pattern.match request.path
      fs << [f, pattern]
    end
  end
  fs.each do |f|
    case f
    when UnboundMethod
      f.bind(self).call
    when Array
      @pre_filter_params = params
      @params = @pre_filter_params.merge f[1].params(request.path)
      f[0].each {|filter| filter.bind(self).call}
      @params = @pre_filter_params
    end
  end
end

#paramsObject



57
58
59
# File 'lib/angelo/mustermann.rb', line 57

def params
  @params ||= super.merge mustermann.params(request.path)
end