Sha256: 0299f423fa39aa418d95ca62bbc33b7b4503a8a7b65a2d68debcaaf8de03f585

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

module Uploadcare
  module Rails
    class Settings
      @@keys = [
        :public_key, :private_key, :upload_url_base,
        :api_url_base, :static_url_base, :api_version,
        :widget_version
      ]
      cattr_reader :keys

      keys.each { |key| attr_accessor key }
      attr_reader :api, :uploader
      

      def initialize(settings = {})
        settings = {
          :widget_version => '0.6.4.2'
        }.update(settings)
        self.class.keys.each do |key|
          send "#{key}=", settings[key] if settings[key].present?
        end
      end

      def get_settings
        Hash[self.class.keys.select{|k| send(k).present? }.map{|k| [k, send(k)]}]
      end

      def make_api
        @api = Uploadcare::Api.new(get_settings)
      end

      def make_uploader
        @uploader = Uploadcare::Uploader.new(get_settings)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uploadcare-rails-0.3 lib/uploadcare/rails/settings.rb