Class: Track::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/track/controller.rb

Constant Summary collapse

@@filters =
FilterMap.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, params) ⇒ Controller

Returns a new instance of Controller.



11
12
13
14
# File 'lib/track/controller.rb', line 11

def initialize(env, params)
  @env    = env
  @params = params
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



9
10
11
# File 'lib/track/controller.rb', line 9

def env
  @env
end

#paramsObject (readonly)

Returns the value of attribute params.



9
10
11
# File 'lib/track/controller.rb', line 9

def params
  @params
end

Class Method Details

.after_filter(method, options = {}) ⇒ Object



38
39
40
# File 'lib/track/controller.rb', line 38

def after_filter(method, options = {})
  @@filters.add(self, :after, method, options)
end

.before_filter(method, options = {}) ⇒ Object



34
35
36
# File 'lib/track/controller.rb', line 34

def before_filter(method, options = {})
  @@filters.add(self, :before, method, options)
end

.filtersObject



30
31
32
# File 'lib/track/controller.rb', line 30

def filters
  @@filters
end

Instance Method Details

#respond(response) ⇒ Object



24
25
26
# File 'lib/track/controller.rb', line 24

def respond(response)
  @_response = response
end

#run_filters(kind, action) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/track/controller.rb', line 16

def run_filters(kind, action)
  @@filters.scan(self.class, kind, action).each do |filter_method|
    self.send(filter_method)
    return @_response if @_response
  end
  nil
end