Sha256: b262dd986fb35b33d010b448d5d6e29666587509fa7fad8c80d32ce440a57add

Contents?: true

Size: 446 Bytes

Versions: 46

Compression:

Stored size: 446 Bytes

Contents

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

46 entries across 46 versions & 6 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/map_type.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/map_type.rb
simple_form-3.4.0 lib/simple_form/map_type.rb
simple_form-3.3.1 lib/simple_form/map_type.rb
simple_form-3.3.0 lib/simple_form/map_type.rb
simple_form-3.2.1 lib/simple_form/map_type.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/simple_form-3.2.0/lib/simple_form/map_type.rb
simple_form-3.2.0 lib/simple_form/map_type.rb
simple_form-3.1.1 lib/simple_form/map_type.rb
simple_form-3.0.4 lib/simple_form/map_type.rb
simple_form-2.1.3 lib/simple_form/map_type.rb
simple_form-2.1.2 lib/simple_form/map_type.rb
simple_form-3.0.3 lib/simple_form/map_type.rb
simple_form-3.1.0 lib/simple_form/map_type.rb
simple_form-3.1.0.rc2 lib/simple_form/map_type.rb
simple_form-3.1.0.rc1 lib/simple_form/map_type.rb
simple_form-3.0.2 lib/simple_form/map_type.rb
simple_form-3.0.1 lib/simple_form/map_type.rb
simple_form-2.1.1 lib/simple_form/map_type.rb
simple_form-3.0.0 lib/simple_form/map_type.rb