Class: ASeriesOfTubes::Tubes::Tube
- Inherits:
-
Object
- Object
- ASeriesOfTubes::Tubes::Tube
- Defined in:
- lib/a_series_of_tubes/tubes/tube.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern, method, controller, action) ⇒ Tube
constructor
A new instance of Tube.
- #matches?(request) ⇒ Boolean
- #run(request, response) ⇒ Object
Constructor Details
#initialize(pattern, method, controller, action) ⇒ Tube
Returns a new instance of Tube.
6 7 8 9 10 11 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 6 def initialize pattern, method, controller, action @pattern = pattern @method = method.to_s.upcase @controller = controller @action = action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
4 5 6 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 4 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
4 5 6 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 4 def controller @controller end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 4 def method @method end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
4 5 6 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 4 def pattern @pattern end |
Instance Method Details
#matches?(request) ⇒ Boolean
13 14 15 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 13 def matches? request self.pattern =~ request.path && request.request_method == self.method end |
#run(request, response) ⇒ Object
17 18 19 20 21 |
# File 'lib/a_series_of_tubes/tubes/tube.rb', line 17 def run request, response params = parse_params_from_path request.path controller = self.controller.new request, response, params controller.invoke_action action end |