Sha256: a05117a547c65776c708045e635fddedf11d62442c8345d6c9eb5ceb688ea155
Contents?: true
Size: 884 Bytes
Versions: 3
Compression:
Stored size: 884 Bytes
Contents
module WithFilters # @private module ValuePrep # A mapping of Rails column types to value preparation class. # # since 0.1.0 TYPE_MAP = { boolean: BooleanPrep, date: DatePrep, datetime: DateTimePrep, timestamp: DateTimePrep } # A factory returning a class that prepares filter values based on a Rails # column type. # # @param [Symbol] column_type A Rails column type. # @param [String] value Value to be passed to the value preparation class. # @param [Hash] options Options to be passed to the value preparation class. # # @return [WithFilters::DefaultPrep, Inherited from WithFilters::DefaultPrep] # # since 0.1.0 def self.prepare(column_type, value, options = {}) (TYPE_MAP[column_type].try(:new, value, options) || DefaultPrep.new(value, options)).value end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
with_filters-0.1.2 | lib/with_filters/value_prep/value_prep.rb |
with_filters-0.1.1 | lib/with_filters/value_prep/value_prep.rb |
with_filters-0.1.0 | lib/with_filters/value_prep/value_prep.rb |