Sha256: 822c95b75f367070fb7827f0a6e1a9c7ec8c7dc3cf4e12177aa561ceb32b97dc

Contents?: true

Size: 621 Bytes

Versions: 7

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.camelize}".constantize rescue Puffer::Inputs::Base)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
puffer-0.0.18 lib/puffer/inputs.rb
puffer-0.0.17 lib/puffer/inputs.rb
puffer-0.0.16 lib/puffer/inputs.rb
puffer-0.0.15 lib/puffer/inputs.rb
puffer-0.0.14 lib/puffer/inputs.rb
puffer-0.0.13 lib/puffer/inputs.rb
puffer-0.0.12 lib/puffer/inputs.rb