Class: Pushable::ConsolePush
- Inherits:
-
Object
- Object
- Pushable::ConsolePush
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/pushable/console_push.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#device_token ⇒ Object
Returns the value of attribute device_token.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#sent_count ⇒ Object
Returns the value of attribute sent_count.
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(attributes = {}) ⇒ ConsolePush
constructor
A new instance of ConsolePush.
Constructor Details
#initialize(attributes = {}) ⇒ ConsolePush
Returns a new instance of ConsolePush.
9 10 11 12 |
# File 'app/models/pushable/console_push.rb', line 9 def initialize(attributes = {}) super @sent_count = 0 end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'app/models/pushable/console_push.rb', line 5 def data @data end |
#device_token ⇒ Object
Returns the value of attribute device_token.
5 6 7 |
# File 'app/models/pushable/console_push.rb', line 5 def device_token @device_token end |
#klass ⇒ Object
Returns the value of attribute klass.
5 6 7 |
# File 'app/models/pushable/console_push.rb', line 5 def klass @klass end |
#sent_count ⇒ Object
Returns the value of attribute sent_count.
5 6 7 |
# File 'app/models/pushable/console_push.rb', line 5 def sent_count @sent_count end |
Instance Method Details
#deliver ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/pushable/console_push.rb', line 14 def deliver data.each do |name, info| setter = "#{name}=" if .respond_to?(setter) value = info['value'] value = value.to_i if info['type'] == 'integer' .send setter, value end end devices.each do |device| if recipient = device.pushable response = .send_to recipient self.sent_count += 1 end end end |