Class: Nisetegami::ARTemplateResolver

Inherits:
ActionView::Resolver
  • Object
show all
Includes:
Singleton
Defined in:
lib/nisetegami/ar_template_resolver.rb

Instance Method Summary collapse

Instance Method Details

#find_templates(name, prefix, partial, details) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/nisetegami/ar_template_resolver.rb', line 7

def find_templates(name, prefix, partial, details)
  Nisetegami::Template.by_mailer(prefix.classify).by_action(name).map do |record|
    formats = [:text]
    formats << :html unless record.only_text?
    formats.map do |format|
      source     = record.send("body_#{format}")
      identifier = "Nisetegami::Template.#{record.id}.#{format}"
      handler    = ActionView::Template.registered_template_handler(:liquid)
      details = {
        format: Mime[format],
        virtual_path: "#{record.mailer.to_s.underscore}/#{record.action}",
        updated_at: record.updated_at
      }
      ActionView::Template.new(source, identifier, handler, details)
    end
  end.flatten
end