Sha256: 844987e394e3c90b376b35c4871b74d6d9f09c97e66b0581c74cc270441cbe85

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Moiper
  class Railtie < Rails::Railtie
    # Expose Moiper's configuration to the Rails application configuration.
    #
    # @example
    #   module MyApplication
    #     class Application < Rails::Application
    #       config.moiper.sandbox = true
    #       config.moiper.token = "teste"
    #       config.moiper.key = "secret"
    #     end
    #   end
    config.moiper = Moiper

    # Load notification controller helper
    initializer "load notification controller helper" do
      require "moiper/notification_controller_helper"
    end

    # Automatically read and configure Moiper with the content
    # of the config/moiper.yml file if it is present
    initializer "load moiper.yml file" do
      config_file = Rails.root.join("config", "moiper.yml")

      if config_file.file?
        yaml = YAML.load(File.read(config_file))[Rails.env]

        if yaml
          Moiper.configure do |config|
            config.sandbox = yaml["sandbox"]
            config.token = yaml["token"]
            config.key = yaml["key"]
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moiper-0.1.2 lib/moiper/railtie.rb