Sha256: b1ac01f152d9cac58d1f381a9572bcbef12dafb3b314fad7e99639053c07d377

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

module Puffer
  module Inputs

    mattr_accessor :mappings
    self.mappings = {}

    def self.map_type *args
      to = args.extract_options![:to]
      args.each { |type| mappings[type] = to }
    end

    map_type :belongs_to, :has_one, :to => Puffer::Inputs::Association
    map_type :has_many, :has_and_belongs_to_many, :to => Puffer::Inputs::CollectionAssociation
    map_type :date, :time, :datetime, :timestamp, :to => Puffer::Inputs::DateTime

    def self.map_field field
      mappings[field.type] || ("Puffer::Inputs::#{field.type.to_s.classify}".constantize rescue Puffer::Inputs::Base)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puffer-0.0.11 lib/puffer/inputs.rb
puffer-0.0.10 lib/puffer/inputs.rb
puffer-0.0.9 lib/puffer/inputs.rb
puffer-0.0.8 lib/puffer/inputs.rb