Class: Orbit::Interceptors::List
- Inherits:
-
Object
- Object
- Orbit::Interceptors::List
- Includes:
- Singleton
- Defined in:
- lib/orbit/interceptors/list.rb
Instance Attribute Summary collapse
-
#interceptors ⇒ Object
readonly
Returns the value of attribute interceptors.
Class Method Summary collapse
- .add_interceptor(path, interceptor_class, excludes = []) ⇒ Object
- .intercept_path(request) ⇒ Object
- .interceptors ⇒ Object
Instance Method Summary collapse
-
#initialize(interceptors = []) ⇒ List
constructor
A new instance of List.
- #interceptors_for_path(path) ⇒ Object
Methods included from Singleton
Constructor Details
#initialize(interceptors = []) ⇒ List
Returns a new instance of List.
7 8 9 |
# File 'lib/orbit/interceptors/list.rb', line 7 def initialize(interceptors=[]) @interceptors = interceptors end |
Instance Attribute Details
#interceptors ⇒ Object (readonly)
Returns the value of attribute interceptors.
5 6 7 |
# File 'lib/orbit/interceptors/list.rb', line 5 def interceptors @interceptors end |
Class Method Details
.add_interceptor(path, interceptor_class, excludes = []) ⇒ Object
11 12 13 14 15 |
# File 'lib/orbit/interceptors/list.rb', line 11 def self.add_interceptor(path, interceptor_class, excludes=[]) interceptor = Item.new(path, interceptor_class, excludes) instance.interceptors.push(interceptor) end |
.intercept_path(request) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/orbit/interceptors/list.rb', line 29 def self.intercept_path(request) path = request.path_info instance.interceptors_for_path(path).each do |hash| result = hash.interceptor_class.execute(request) return result if result end nil end |
.interceptors ⇒ Object
17 18 19 |
# File 'lib/orbit/interceptors/list.rb', line 17 def self.interceptors instance.interceptors end |
Instance Method Details
#interceptors_for_path(path) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/orbit/interceptors/list.rb', line 21 def interceptors_for_path(path) return [] unless path interceptors.select do |item| item.match_path?(path) end end |