Sha256: fbf4f42cddf91fba22eca7ac8172837ee32508c955ca6c68026622d17781aed1

Contents?: true

Size: 476 Bytes

Versions: 11

Compression:

Stored size: 476 Bytes

Contents

# frozen_string_literal: true
require 'active_support/core_ext/class/attribute'

module SimpleForm
  module MapType
    def self.extended(base)
      base.class_attribute :mappings
      base.mappings = {}
    end

    def map_type(*types)
      map_to = types.extract_options![:to]
      raise ArgumentError, "You need to give :to as option to map_type" unless map_to
      self.mappings = mappings.merge types.each_with_object({}) { |t, m| m[t] = map_to }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
simple_form-5.3.0 lib/simple_form/map_type.rb
simple_form-5.2.0 lib/simple_form/map_type.rb
simple_form-5.1.0 lib/simple_form/map_type.rb
simple_form-5.0.3 lib/simple_form/map_type.rb
simple_form-5.0.2 lib/simple_form/map_type.rb
simple_form-5.0.1 lib/simple_form/map_type.rb
simple_form-5.0.0 lib/simple_form/map_type.rb
simple_form-4.1.0 lib/simple_form/map_type.rb
simple_form-4.0.1 lib/simple_form/map_type.rb
simple_form-4.0.0 lib/simple_form/map_type.rb
simple_form-3.5.1 lib/simple_form/map_type.rb