Class: Mailtime::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/mailtime/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mailtime/configuration.rb', line 20

def initialize
  @mailers = load_mailers
  @render = true
  @log = true
  @log_fields = [:to]
  @fallback = true
  @reject_scope_keys = ['devise_mapping', 'scope_name']
  @loggable_lookups = Mailtime.loggable_lookups
  @yield_keyword = '{{ mailtime_yield }}'
  @valid_formats = %w{html text}
end

Instance Attribute Details

#fallbackObject

Returns the value of attribute fallback.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def fallback
  @fallback
end

#logObject

Returns the value of attribute log.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def log
  @log
end

#log_fieldsObject

Returns the value of attribute log_fields.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def log_fields
  @log_fields
end

#loggable_lookupsObject

Returns the value of attribute loggable_lookups.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def loggable_lookups
  @loggable_lookups
end

#mailersObject

Returns the value of attribute mailers.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def mailers
  @mailers
end

#reject_scope_keysObject

Returns the value of attribute reject_scope_keys.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def reject_scope_keys
  @reject_scope_keys
end

#renderObject

Returns the value of attribute render.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def render
  @render
end

#valid_formatsObject

Returns the value of attribute valid_formats.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def valid_formats
  @valid_formats
end

#yield_keywordObject

Returns the value of attribute yield_keyword.



10
11
12
# File 'lib/mailtime/configuration.rb', line 10

def yield_keyword
  @yield_keyword
end

Class Method Details

.loggable_lookupsObject



43
44
45
# File 'lib/mailtime/configuration.rb', line 43

def self.loggable_lookups
  @loggable_lookups ||= []
end

.loggable_lookups=(val) ⇒ Object

does nothing on purpose.



48
49
50
# File 'lib/mailtime/configuration.rb', line 48

def self.loggable_lookups=(val)
  @loggable_lookups
end

Instance Method Details

#load_mailersObject



65
66
67
# File 'lib/mailtime/configuration.rb', line 65

def load_mailers
  ObjectSpace.each_object(Class).select { |klass| klass < ::ActionMailer::Base }
end

#loggablesObject



36
37
38
39
40
41
# File 'lib/mailtime/configuration.rb', line 36

def loggables
  @loggable_lookups.each_with_object({}) do |k,h|
    key = k.keys.first
    h[key] = k[key]
  end
end

#mailer(klass) ⇒ Object



32
33
34
# File 'lib/mailtime/configuration.rb', line 32

def mailer(klass)
  @mailers << klass
end

#preload_mailersObject



60
61
62
63
# File 'lib/mailtime/configuration.rb', line 60

def preload_mailers
  Dir.glob(::Rails.root.join("app/mailers/**/*_mailer.rb"))
      .each { |klass| require klass }
end

#preload_mailers!Object



56
57
58
# File 'lib/mailtime/configuration.rb', line 56

def preload_mailers!
  preload_mailers
end

#valid_extensionsObject



52
53
54
# File 'lib/mailtime/configuration.rb', line 52

def valid_extensions
  Mailtime::Renderers::BaseRenderer.descendants.map(&:renders).flatten
end