Sha256: 70f51c4c4a9042fd327f996b325372976507598099031c9211f90806488f6b9e

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require 'yaml'

module S3CorsFileupload
  module Config

    # 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(ERB.new(File.read(File.join(::Rails.root, 'config', 'amazon_s3.yml'))).result)[::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

1 entries across 1 versions & 1 rubygems

Version Path
s3_cors_fileupload-0.1.5 lib/s3_cors_fileupload/rails/config.rb