Class: Twing::Receivers
- Inherits:
-
Object
- Object
- Twing::Receivers
- Defined in:
- lib/twing/receivers.rb
Instance Attribute Summary collapse
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#receivers ⇒ Object
readonly
Returns the value of attribute receivers.
Instance Method Summary collapse
- #add(receiver) ⇒ Object
- #init(app) ⇒ Object
-
#initialize ⇒ Receivers
constructor
A new instance of Receivers.
- #run(&block) ⇒ Object
Constructor Details
#initialize ⇒ Receivers
Returns a new instance of Receivers.
5 6 7 |
# File 'lib/twing/receivers.rb', line 5 def initialize @receivers, @instances = [], [] end |
Instance Attribute Details
#instances ⇒ Object (readonly)
Returns the value of attribute instances.
3 4 5 |
# File 'lib/twing/receivers.rb', line 3 def instances @instances end |
#receivers ⇒ Object (readonly)
Returns the value of attribute receivers.
3 4 5 |
# File 'lib/twing/receivers.rb', line 3 def receivers @receivers end |
Instance Method Details
#add(receiver) ⇒ Object
9 10 11 |
# File 'lib/twing/receivers.rb', line 9 def add(receiver) @receivers << receiver end |
#init(app) ⇒ Object
13 14 15 16 17 |
# File 'lib/twing/receivers.rb', line 13 def init(app) @instances = @receivers.map do |receiver| receiver.new(app) end end |
#run(&block) ⇒ Object
19 20 21 |
# File 'lib/twing/receivers.rb', line 19 def run(&block) @instances.each(&block) end |