Sha256: cefbb2bfa73669159ae7d68f88a227eee5131547294735518f02ced1f1409d5a

Contents?: true

Size: 1.93 KB

Versions: 7

Compression:

Stored size: 1.93 KB

Contents

# encoding: utf-8

module CarrierWave
  module Qiniu
    module Configuration
      extend ActiveSupport::Concern
      included do
        add_config :qiniu_bucket_domain
        add_config :qiniu_bucket
        add_config :qiniu_bucket_private
        add_config :qiniu_access_key
        add_config :qiniu_secret_key
        add_config :qiniu_block_size
        add_config :qiniu_protocol
        add_config :qiniu_async_ops
        add_config :qiniu_persistent_notify_url
        add_config :qiniu_callback_url
        add_config :qiniu_callback_body
        add_config :qiniu_can_overwrite
        add_config :qiniu_expires_in
        add_config :qiniu_up_host
        add_config :qiniu_private_url_expires_in
        add_config :qiniu_style_separator
        add_config :qiniu_style_inline
        add_config :qiniu_styles

        alias_config :qiniu_protocal, :qiniu_protocol

        reset_qiniu_config
      end

      module ClassMethods
        # Set default value
        def reset_qiniu_config
          configure do |config|
            config.qiniu_protocol = 'http'
            config.qiniu_bucket_private = false
            config.qiniu_block_size = 1024*1024*4
            config.qiniu_async_ops = ''
            config.qiniu_can_overwrite = false
            config.qiniu_private_url_expires_in = 3600
            config.qiniu_callback_url = ''
            config.qiniu_callback_body = ''
            config.qiniu_persistent_notify_url = ''
            config.qiniu_style_separator = '-'
            config.qiniu_style_inline = false
          end
        end

        def alias_config(new_name, old_name)
          class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def self.#{new_name}(value=nil)
            self.#{old_name}(value)
          end

          def self.#{new_name}=(value)
            self.#{old_name}=(value)
          end

          def #{new_name}
          #{old_name}
          end
          RUBY
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
carrierwave-qiniu-1.1.4 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.1.3 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.1.2 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.1.1 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.1.0 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.0.1 lib/carrierwave/qiniu/configuration.rb
carrierwave-qiniu-1.0.0 lib/carrierwave/qiniu/configuration.rb