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
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(path) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/orbit/interceptors/list.rb', line 25 def self.intercept_path(path) instance.interceptors_for_path(path).each do |hash| result = hash.interceptor_class.execute return result if result end nil end |
Instance Method Details
#interceptors_for_path(path) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/orbit/interceptors/list.rb', line 17 def interceptors_for_path(path) return [] unless path interceptors.select do |item| item.match_path?(path) end end |