Class: Courier::Service::Base
- Inherits:
-
Object
- Object
- Courier::Service::Base
show all
- Defined in:
- lib/courier/service/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.config ⇒ Object
32
33
34
|
# File 'lib/courier/service/base.rb', line 32
def config
@config
end
|
28
29
30
|
# File 'lib/courier/service/base.rb', line 28
def configure
yield @config
end
|
.inherited(subclass) ⇒ Object
23
24
25
26
|
# File 'lib/courier/service/base.rb', line 23
def inherited(subclass)
subclass.instance_variable_set('@config', OpenStruct.new)
super
end
|
Instance Method Details
#check_args(owner, template, args) ⇒ Object
37
38
39
|
# File 'lib/courier/service/base.rb', line 37
def check_args owner, template, args
end
|
#deliver_all! ⇒ Object
66
67
68
69
70
|
# File 'lib/courier/service/base.rb', line 66
def deliver_all!
messages.fresh.each do |message|
deliver_message(message) and message.mark_as_delivered!
end
end
|
#deliver_message(message) ⇒ Object
58
59
60
|
# File 'lib/courier/service/base.rb', line 58
def deliver_message(message)
raise 'inherit and implement me'
end
|
#message(owner, template, args) ⇒ Object
41
42
43
44
|
# File 'lib/courier/service/base.rb', line 41
def message(owner, template, args)
check_args owner, template, args
Courier::Message.create! :owner=>owner, :template=>template.name, :service=>name, :options=>args
end
|
#messages ⇒ Object
62
63
64
|
# File 'lib/courier/service/base.rb', line 62
def messages
Courier::Message.by_service(name)
end
|
#name ⇒ Object
54
55
56
|
# File 'lib/courier/service/base.rb', line 54
def name
self.class.name.demodulize.underscore.to_sym
end
|
#to_label ⇒ Object
50
51
52
|
# File 'lib/courier/service/base.rb', line 50
def to_label
I18n::translate(:label, :scope=>[:courier, :services, name] )
end
|
#to_s ⇒ Object
46
47
48
|
# File 'lib/courier/service/base.rb', line 46
def to_s
name
end
|