Sha256: 95537b2cb515a73acc3f0b548e0e0900a7690ee1db8df9c56946e5e73e9bc0b6

Contents?: true

Size: 436 Bytes

Versions: 4

Compression:

Stored size: 436 Bytes

Contents

require 'active_support/core_ext/class/attribute'

module MightyGrid
  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.merge! types.each_with_object({}) { |t, m| m[t] = map_to }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mighty_grid-2.1.1 lib/mighty_grid/map_type.rb
mighty_grid-2.1.0 lib/mighty_grid/map_type.rb
mighty_grid-2.0.0 lib/mighty_grid/map_type.rb
mighty_grid-2.0.0.rc1 lib/mighty_grid/map_type.rb