Class: Axeman::Subscriber
- Inherits:
-
Object
- Object
- Axeman::Subscriber
- Defined in:
- lib/axeman/subscriber.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
Instance Method Summary collapse
-
#initialize ⇒ Subscriber
constructor
A new instance of Subscriber.
- #notice(controller, action) ⇒ Object
- #subscribe! ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize ⇒ Subscriber
Returns a new instance of Subscriber.
5 6 |
# File 'lib/axeman/subscriber.rb', line 5 def initialize end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
3 4 5 |
# File 'lib/axeman/subscriber.rb', line 3 def actions @actions end |
Instance Method Details
#notice(controller, action) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/axeman/subscriber.rb', line 8 def notice(controller, action) self.actions ||= {} self.actions[controller] ||= Hash.new self.actions[controller][action] ||= 0 self.actions[controller][action] += 1 end |
#subscribe! ⇒ Object
15 16 17 18 19 20 |
# File 'lib/axeman/subscriber.rb', line 15 def subscribe! ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*args| event = ActiveSupport::Notifications::Event.new(*args) notice(event.payload[:controller], event.payload[:action]) end end |
#total ⇒ Object
22 23 24 |
# File 'lib/axeman/subscriber.rb', line 22 def total actions end |