Class: Track::FilterMap
- Inherits:
-
Object
- Object
- Track::FilterMap
- Defined in:
- lib/track/filter_map.rb
Instance Method Summary collapse
- #add(klass, kind, method, options = {}) ⇒ Object
-
#initialize ⇒ FilterMap
constructor
A new instance of FilterMap.
- #scan(klass, kind, action) ⇒ Object
Constructor Details
#initialize ⇒ FilterMap
Returns a new instance of FilterMap.
6 7 8 |
# File 'lib/track/filter_map.rb', line 6 def initialize @filters = {} end |
Instance Method Details
#add(klass, kind, method, options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/track/filter_map.rb', line 10 def add(klass, kind, method, = {}) @filters[kind] ||= [] @filters[kind] << [method, , klass] end |
#scan(klass, kind, action) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/track/filter_map.rb', line 15 def scan(klass, kind, action) filters = [] if @filters[kind] @filters[kind].each do |method, , k| next if contains?([:except], action) || !(klass <= k) filters << method if contains?([:only], action) || blank?([:only]) end end filters end |