Module: RTPush

Defined in:
lib/rtpush.rb,
lib/rtpush/version.rb,
lib/rtpush/adapters/fcm_adapter.rb,
lib/rtpush/adapters/base_adapter.rb,
lib/rtpush/adapters/rpush_adapter.rb,
lib/rtpush/adapters/slack_adapter.rb,
lib/rtpush/adapters/twilio_adapter.rb,
lib/rtpush/adapters/instapush_adapter.rb

Defined Under Namespace

Modules: VERSION Classes: BaseAdapter, FcmAdapter, InstapushAdapter, PresenceValidator, RpushAdapter, SlackAdapter, TwilioAdapter

Class Method Summary collapse

Class Method Details

.initialize(options, message) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/rtpush.rb', line 6

def self.initialize(options, message)
  raise ArgumentError, 'Missing Message param' if message.to_s.empty?
  raise ArgumentError, 'Missing Arguments params' if options.empty?
  push(strategies(options), message)
end

.push(strategies, message) ⇒ Object



14
15
16
17
18
# File 'lib/rtpush.rb', line 14

def self.push(strategies, message)
  strategies.each do |strategy|
    strategy.push(message)
  end
end

.strategies(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rtpush.rb', line 20

def self.strategies(options)
  strategies = []
  options.each do |option|
    case option
    when 'sms'
      strategies << RTPush::TwilioAdapter
    when 'mobile'
      strategies << RTPush::FcmAdapter
    when 'insta'
      strategies << RTPush::InstapushAdapter
    when 'slack'
      strategies << RTPush::SlackAdapter
    else
      raise Errors::NotImplementedStrategyError, "Unknown strategy #{option}"
    end
  end
  strategies
end