Class: Hanami::Mailer::DSL::BoundAttachment Private

Inherits:
Object
  • Object
show all
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.

A bound attachment definition that can be evaluated in the context of a mailer instance.

Instance Method Summary collapse

Constructor Details

#initialize(name_or_filename, proc, object, **options) ⇒ BoundAttachment

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 BoundAttachment.



67
68
69
70
71
72
# File 'lib/hanami/mailer/dsl/attachments.rb', line 67

def initialize(name_or_filename, proc, object, **options)
  @name_or_filename = name_or_filename
  @object = object
  @options = options
  @callable = PluckyProc.from_name(proc, name_or_filename, object) || static_callable
end

Instance Method Details

#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 attachment definition and returns an array of Attachment objects.

Positional parameters resolve against ‘dependencies` (the mailer’s exposure values); keyword parameters resolve against ‘input`.



78
79
80
# File 'lib/hanami/mailer/dsl/attachments.rb', line 78

def call(input, dependencies = {})
  Array(@callable.call(input, *dependency_args(dependencies))).each { ensure_attachment(_1) }
end