Sha256: 4cc56ddde9ed59217cd6fa52cf59b39ff00f146db34365211a69e35360e7243a

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

module S3CorsFileupload
  module Config
    require 'yaml'

    # this allows us to lazily instantiate the configuration by reading it in when it needs to be accessed
    class << self
      # if a method is called on the class, attempt to look it up in the config array
      def method_missing(meth, *args, &block)
        if args.empty? && block.nil?
          config[meth.to_s]
        else
          super
        end
      end

      private

      def config
        @config ||= YAML.load_file(File.join(::Rails.root, 'config', 'amazon_s3.yml'))[::Rails.env]
      rescue
        warn('WARNING: s3_cors_fileupload gem was unable to locate a configuration file in config/amazon_s3.yml and may not ' +
             'be able to function properly.  Please run `rails generate s3_cors_upload:install` before proceeding.')
        {}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
s3_cors_fileupload-0.1.2 lib/s3_cors_fileupload/rails/config.rb
s3_cors_fileupload-0.1.1 lib/s3_cors_fileupload/rails/config.rb