Class: Hanami::Mailer::DSL::Attachments Private
- Inherits:
-
Object
- Object
- Hanami::Mailer::DSL::Attachments
- Defined in:
- lib/hanami/mailer/dsl/attachments.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Collection of class-level attachment definitions for a mailer.
Instance Attribute Summary collapse
- #definitions ⇒ Object readonly private
Instance Method Summary collapse
- #add(name_or_filename, proc = nil, **options) ⇒ Object private
-
#bind(obj) ⇒ Object
private
Returns a copy with every definition bound to the mailer instance.
-
#call(input, dependencies: {}) ⇒ Object
private
Evaluates the bound definitions, returning an AttachmentSet of Attachment instances.
-
#initialize(definitions = []) ⇒ Attachments
constructor
private
A new instance of Attachments.
Constructor Details
#initialize(definitions = []) ⇒ Attachments
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Attachments.
12 13 14 |
# File 'lib/hanami/mailer/dsl/attachments.rb', line 12 def initialize(definitions = []) @definitions = definitions end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/hanami/mailer/dsl/attachments.rb', line 10 def definitions @definitions end |
Instance Method Details
#add(name_or_filename, proc = nil, **options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/hanami/mailer/dsl/attachments.rb', line 21 def add(name_or_filename, proc = nil, **) definitions << Attachment.new(name_or_filename, proc, **) end |
#bind(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a copy with every definition bound to the mailer instance.
26 27 28 |
# File 'lib/hanami/mailer/dsl/attachments.rb', line 26 def bind(obj) self.class.new(definitions.map { |definition| definition.bind(obj) }) end |
#call(input, dependencies: {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Evaluates the bound definitions, returning an AttachmentSet of Hanami::Mailer::DSL::Attachment instances.
Each definition’s positional parameters resolve against ‘dependencies` (the mailer’s exposure values); its keyword parameters resolve against ‘input` (the raw `deliver` input).
34 35 36 37 38 |
# File 'lib/hanami/mailer/dsl/attachments.rb', line 34 def call(input, dependencies: {}) = definitions.flat_map { |definition| definition.call(input, dependencies) } AttachmentSet.new() end |