Class: Nuntius::BaseProvider

Inherits:
Object
  • Object
show all
Defined in:
app/providers/nuntius/base_provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(message = nil)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'app/providers/nuntius/base_provider.rb', line 5

def message
  @message
end

Class Method Details

.all_settingsObject



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

#deliverObject

Override this in implementations



40
41
42
# File 'app/providers/nuntius/base_provider.rb', line 40

def deliver
  @message
end

#nameObject



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

#refreshObject

Override this in implementations



45
46
47
# File 'app/providers/nuntius/base_provider.rb', line 45

def refresh
  @message
end