Class: Celebrations::Mailer::MailEnvironment
- Inherits:
-
Object
- Object
- Celebrations::Mailer::MailEnvironment
show all
- Defined in:
- lib/release_party/celebrations/mailer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(environment, mail) ⇒ MailEnvironment
Returns a new instance of MailEnvironment.
14
15
16
17
18
|
# File 'lib/release_party/celebrations/mailer.rb', line 14
def initialize(environment, mail)
@environment = environment
@mail = mail
@attachments = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
37
38
39
|
# File 'lib/release_party/celebrations/mailer.rb', line 37
def method_missing(method_id, *args, &block)
@environment.method_missing(method_id, *args, &block)
end
|
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
12
13
14
|
# File 'lib/release_party/celebrations/mailer.rb', line 12
def attachments
@attachments
end
|
Instance Method Details
#image_file(filename) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/release_party/celebrations/mailer.rb', line 26
def image_file(filename)
path = File.join(File.dirname(@environment.template), filename)
@mail.attachments.inline[File.basename(path)] = File.read(path)
@attachments << attachment = @mail.attachments.inline[File.basename(path)]
attachment.url
end
|
#image_tag(filename, options = {}) ⇒ Object
33
34
35
|
# File 'lib/release_party/celebrations/mailer.rb', line 33
def image_tag(filename, options = {})
%{<img src="#{image_file(filename)}" #{options_to_tag_attrs options}/>}
end
|
#options_to_tag_attrs(options) ⇒ Object
20
21
22
23
24
|
# File 'lib/release_party/celebrations/mailer.rb', line 20
def options_to_tag_attrs(options)
options.inject([]) do |memo, (key, value)|
memo << %{#{key}="#{value}"}
end.join(' ')
end
|