Class: Nuntius::BaseProvider
- Inherits:
-
Object
- Object
- Nuntius::BaseProvider
- Defined in:
- app/providers/nuntius/base_provider.rb
Direct Known Subclasses
ApnoticPushProvider, FirebasePushProvider, HoustonPushProvider, MessageBirdSmsProvider, SlackSlackProvider, SmstoolsSmsProvider, SmtpMailProvider, TeamsTeamsProvider, TwilioSmsProvider, TwilioVoiceProvider
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
- .all_settings ⇒ Object
- .class_from_name(name, transport) ⇒ Object
- .setting_reader(name, required: false, default: nil, description: "") ⇒ Object
- .states(mapping = nil) ⇒ Object
- .transport(transport = nil) ⇒ Object
Instance Method Summary collapse
-
#callback(_params) ⇒ Object
Override this in implementation.
-
#deliver ⇒ Object
Override this in implementations.
-
#initialize(message = nil) ⇒ BaseProvider
constructor
A new instance of BaseProvider.
- #name ⇒ Object
-
#refresh ⇒ Object
Override this in implementations.
Constructor Details
#initialize(message = nil) ⇒ BaseProvider
Returns a new instance of BaseProvider.
7 8 9 |
# File 'app/providers/nuntius/base_provider.rb', line 7 def initialize( = nil) @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'app/providers/nuntius/base_provider.rb', line 5 def @message end |
Class Method Details
.all_settings ⇒ Object
12 13 14 |
# File 'app/providers/nuntius/base_provider.rb', line 12 def all_settings @all_settings ||= [] end |
.class_from_name(name, transport) ⇒ Object
32 33 34 35 36 |
# File 'app/providers/nuntius/base_provider.rb', line 32 def class_from_name(name, transport) Nuntius.const_get("#{name}_#{transport}_provider".camelize) rescue nil end |
.setting_reader(name, required: false, default: nil, description: "") ⇒ Object
16 17 18 19 20 |
# File 'app/providers/nuntius/base_provider.rb', line 16 def setting_reader(name, required: false, default: nil, description: "") @all_settings ||= [] @all_settings.push(name: name, required: required, default: default, description: description) define_method(name) { required ? settings.fetch(name) : settings[name] || default } end |
.states(mapping = nil) ⇒ Object
27 28 29 30 |
# File 'app/providers/nuntius/base_provider.rb', line 27 def states(mapping = nil) @states = mapping if mapping @states end |
.transport(transport = nil) ⇒ Object
22 23 24 25 |
# File 'app/providers/nuntius/base_provider.rb', line 22 def transport(transport = nil) @transport = transport if transport @transport end |
Instance Method Details
#callback(_params) ⇒ Object
Override this in implementation
50 51 52 |
# File 'app/providers/nuntius/base_provider.rb', line 50 def callback(_params) [404, {"Content-Type" => "text/html; charset=utf-8"}, ["Not found"]] end |
#deliver ⇒ Object
Override this in implementations
40 41 42 |
# File 'app/providers/nuntius/base_provider.rb', line 40 def deliver @message end |
#name ⇒ Object
54 55 56 |
# File 'app/providers/nuntius/base_provider.rb', line 54 def name self.class.name.demodulize.underscore.gsub(/_#{self.class.transport}_provider$/, "").to_sym end |
#refresh ⇒ Object
Override this in implementations
45 46 47 |
# File 'app/providers/nuntius/base_provider.rb', line 45 def refresh @message end |