Sha256: e34f8a94c7b35efdc96ade38bdf9e89c012454696da8d99320e759f9ddd4b5e0
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
module Puffer module Customs # Custom field types mattr_accessor :types self.types = [] def self.map_type &block types.unshift block if block_given? end def self.type_for field swallow_nil{ types.detect { |offer| offer.call(field) }.call(field) } end map_type { |field| :select if field.options.key?(:select) } map_type { |field| :password if field.name =~ /password/ } map_type { |field| swallow_nil{ field.reflection.macro } } # Custom inputs mattr_accessor :inputs self.inputs = {} def self.map_input *args to = args.extract_options![:to] args.each { |type| inputs[type] = to } end def self.input_for field inputs[field.type] || ("Puffer::Inputs::#{field.type.to_s.camelize}".constantize rescue Puffer::Inputs::Base) end map_input :belongs_to, :has_one, :to => Puffer::Inputs::Association map_input :has_many, :has_and_belongs_to_many, :to => Puffer::Inputs::CollectionAssociation map_input :date, :time, :datetime, :timestamp, :to => Puffer::Inputs::DateTime # Customs renderers mattr_accessor :renderers self.renderers = {} def self.map_renderer *args to = args.extract_options![:to] args.each { |type| renderers[type] = to } end # Customs filters mattr_accessor :filters self.filters = {} def self.map_filter *args to = args.extract_options![:to] args.each { |type| filters[type] = to } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
puffer-0.0.23 | lib/puffer/customs.rb |
puffer-0.0.22 | lib/puffer/customs.rb |
puffer-0.0.21 | lib/puffer/customs.rb |
puffer-0.0.20 | lib/puffer/customs.rb |