Sha256: 90b010824832ccb3bcab35a6c94fb90351b70add3928bd914ae0f95c3526d0c4

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module CarrierWave
  module UpYun
    module Configuration
      extend ActiveSupport::Concern
      included do
        add_config :upyun_username
        add_config :upyun_password
        add_config :upyun_bucket
        add_config :upyun_api_host
        add_config :upyun_bucket_host
      end
    end

    module ClassMethods
      def add_config(name)
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def self.#{name}(value=nil)
            @#{name} = value if value
            return @#{name} if self.object_id == #{object_id} || defined?(@#{name})
            name = superclass.#{name}
            return nil if name.nil? && !instance_variable_defined?("@#{name}")
            @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name
          end

          def self.#{name}=(value)
            @#{name} = value
          end

          def #{name}
            value = self.class.#{name}
            value.instance_of?(Proc) ? value.call : value
          end
        RUBY
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
carrierwave-upyun-2.0.0 lib/carrierwave/upyun/configuration.rb
carrierwave-upyun-1.0.5 lib/carrierwave/upyun/configuration.rb
carrierwave-upyun-1.0.4 lib/carrierwave/upyun/configuration.rb
carrierwave-upyun-1.0.3 lib/carrierwave/upyun/configuration.rb
carrierwave-upyun-1.0.2 lib/carrierwave/upyun/configuration.rb
carrierwave-upyun-1.0.1 lib/carrierwave/upyun/configuration.rb