Sha256: 3b8b33d2470763749b741be582c7ca844ffa78db77fd4946e79635a9a2b09a1c

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module CarrierWave
  module Meta
    module ActiveRecord
      ALLOWED = %w(width height md5sum image_size file_size content_type)

      def carrierwave_meta_composed(single_attribute, *args)
        defined_attrs = args.map do |arg|
          name, to_define = if arg.is_a?(Symbol)
            [arg, ALLOWED]
          elsif arg.is_a?(Hash)
            [arg.keys.first, arg.values.first]
          end

          to_define.map do |attr|
            delegate :"#{name}_#{attr}", to: single_attribute, allow_nil: true
            delegate :"#{name}_#{attr}=", to: single_attribute, allow_nil: true
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
carrierwave-meta-0.0.7 lib/carrierwave-meta/active_record.rb
carrierwave-meta-0.0.5 lib/carrierwave-meta/active_record.rb