Class: DevelopmentNotification::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



16
17
18
# File 'lib/development_notification.rb', line 16

def domain
  @domain
end

#leadersend_api_keyObject

Returns the value of attribute leadersend_api_key.



16
17
18
# File 'lib/development_notification.rb', line 16

def leadersend_api_key
  @leadersend_api_key
end

#leadersend_usernameObject

Returns the value of attribute leadersend_username.



16
17
18
# File 'lib/development_notification.rb', line 16

def leadersend_username
  @leadersend_username
end

Class Method Details

.email_sendingObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/development_notification.rb', line 24

def self.email_sending
  Leadersend.configure do |config|
    config.username = DevelopmentNotification.config.leadersend_username
    config.api_key  = DevelopmentNotification.config.leadersend_api_key
  end

  ActionMailer::Base.smtp_settings = {
    :address        => Leadersend.config.host,
    :port           => '587',
    :authentication => :plain,
    :user_name      => Leadersend.config.username,
    :password       => Leadersend.config.api_key,
    :domain         => DevelopmentNotification.config.domain
  }

  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.default_url_options[:host] = DevelopmentNotification.config.domain
end

Instance Method Details

#validate!Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/development_notification.rb', line 18

def validate!
  raise ArgumentError.new("DevelopmentNotification did not receive all three configuration pieces!") unless @leadersend_username && @leadersend_api_key && @domain
  Config.email_sending
  return true
end