Module: Knitkit::Extensions::ActionMailer::ThemeSupport::ActsAsThemedMailer::InstanceMethods

Defined in:
lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb

Instance Method Summary collapse

Instance Method Details

#add_theme_view_paths(website) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb', line 22

def add_theme_view_paths(website)
  ThemeSupport::Cache.theme_resolvers = [] if ThemeSupport::Cache.theme_resolvers.nil?
  current_theme_paths(website).each do |theme|
    resolver = case Rails.application.config.erp_tech_svcs.file_storage
                 when :s3
                   path = File.join(theme[:url], "templates")
                   cached_resolver = ThemeSupport::Cache.theme_resolvers.find { |cached_resolver| cached_resolver.to_path == path }
                   if cached_resolver.nil?
                     resolver = ActionView::S3Resolver.new(path)
                     ThemeSupport::Cache.theme_resolvers << resolver
                     resolver
                   else
                     cached_resolver
                   end
                 when :filesystem
                   path = "#{theme[:path]}/templates"
                   cached_resolver = ThemeSupport::Cache.theme_resolvers.find { |cached_resolver| cached_resolver.to_path == path }
                   if cached_resolver.nil?
                     resolver = ActionView::ThemeFileResolver.new(path)
                     ThemeSupport::Cache.theme_resolvers << resolver
                     resolver
                   else
                     cached_resolver
                   end
               end
    prepend_view_path(resolver)
  end
end

#current_theme_paths(website) ⇒ Object



51
52
53
# File 'lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb', line 51

def current_theme_paths(website)
  website.nil? ? [] : website.themes.active.map { |theme| {:path => theme.path.to_s, :url => theme.url.to_s} }
end