Sha256: dc2ff07b1f5cd9d648f716007f80eac7284f90c5da3f1e2cbd7fbca4c33f550e
Contents?: true
Size: 1.47 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
puffer-0.0.19 | lib/puffer/customs.rb |