Class: Kahuna::Handler
- Inherits:
-
Object
- Object
- Kahuna::Handler
- Defined in:
- lib/kahuna/handler.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#members ⇒ Object
readonly
Returns the value of attribute members.
Instance Method Summary collapse
- #execute(&block) ⇒ Object
-
#initialize(data, &block) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(data, &block) ⇒ Handler
Returns a new instance of Handler.
8 9 10 11 12 13 14 |
# File 'lib/kahuna/handler.rb', line 8 def initialize(data, &block) @event = Event.new data unless event.type == 'user' @members = MemberCollection.new data end @action = block_given? ? block : ->(event, members) {} end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
6 7 8 |
# File 'lib/kahuna/handler.rb', line 6 def event @event end |
#members ⇒ Object (readonly)
Returns the value of attribute members.
6 7 8 |
# File 'lib/kahuna/handler.rb', line 6 def members @members end |
Instance Method Details
#execute(&block) ⇒ Object
16 17 18 19 |
# File 'lib/kahuna/handler.rb', line 16 def execute &block block_to_call = block_given? ? block : @action block_to_call.call(event, members) end |