Class: ActionShortMessage::Interceptor
- Inherits:
-
Object
- Object
- ActionShortMessage::Interceptor
- Defined in:
- lib/action_short_message/interceptor.rb
Class Method Summary collapse
Class Method Details
.register(conditions = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/action_short_message/interceptor.rb', line 7 def register(conditions = {}) raise TypeError, 'Invalid type. Please provide a hash object' unless conditions.methods.include?(:key) conditions.each do |attribute, condition| @@blacklist[attribute.to_sym] ||= [] @@blacklist[attribute.to_sym].push(condition) end end |
.registered_for?(message) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/action_short_message/interceptor.rb', line 16 def registered_for?() @@blacklist.each do |attribute, conditions| value = .send(attribute.to_sym) conditions.each do |condition| return true if value.send(match_method_for(condition), condition) end end false end |