Module: PostageApp

Defined in:
lib/postageapp.rb,
lib/postageapp/version.rb

Defined Under Namespace

Modules: FailedRequest, Rails Classes: Configuration, Error, Logger, Mail, Mailer, Railtie, Request, Response

Constant Summary collapse

VERSION =
"1.2.0"

Class Method Summary collapse

Class Method Details

.configurationObject Also known as: config

Accessor for the PostageApp::Configuration object Example use:

PostageApp.configuration.api_key = '1234567890abcdef'


41
42
43
# File 'lib/postageapp.rb', line 41

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Call this method to modify your configuration Example:

PostageApp.configure do |config|
  config.api_key             = '1234567890abcdef'
  config.recipient_override  = '[email protected]' if Rails.env.staging?
end

If you do not want/need to initialize the gem in this way, you can use the environment variable POSTAGEAPP_API_KEY to set up your key.

Yields:



34
35
36
# File 'lib/postageapp.rb', line 34

def self.configure
  yield(configuration)
end

.loggerObject

Logger for the plugin



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/postageapp.rb', line 50

def self.logger
  @logger ||= begin
    configuration.logger || PostageApp::Logger.new(
      if (configuration.project_root)
        FileUtils.mkdir_p(File.join(File.expand_path(configuration.project_root), 'log'))
        File.join(configuration.project_root, "log/postageapp_#{configuration.environment}.log")
      else
        STDOUT
      end
    )
  end
end