Sha256: fbe00b6397a3a03c90ffc9084a10ed77edc359102e67ffd1fc1cf812b0e0ceed

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

module WithFilters
  # @private
  module Filter
    TYPES = {
      :'datetime-local' => Text,
      text:     Text,
      email:    Text,
      url:      Text,
      tel:      Text,
      number:   Text,
      range:    Text,
      date:     Text,
      month:    Text,
      week:     Text,
      time:     Text,
      datetime: Text,
      search:   Text,
      color:    Text,
      hidden:   Text,
      checkbox: CheckBox,
      radio:    Radio,
      select:   Select
    }

    RANGED_TYPES = {
      :'datetime-local' => TextRange,
      text:     TextRange,
      email:    TextRange,
      url:      TextRange,
      tel:      TextRange,
      number:   TextRange,
      range:    TextRange,
      date:     TextRange,
      month:    TextRange,
      week:     TextRange,
      time:     TextRange,
      datetime: TextRange,
      search:   TextRange,
      color:    TextRange,
      select:   SelectRange
    }

    def self.create(name, namespace, value, options = {})
      as = options.delete(:as)

      options[:type] = as.to_s

      TYPES[as].new(name, namespace, value, options)
    end

    def self.create_range(name, namespace, value, options = {})
      as = options.delete(:as)

      options[:type] = as.to_s

      RANGED_TYPES[as].new(name, namespace, value, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
with_filters-0.1.2 lib/with_filters/models/filter/filter.rb
with_filters-0.1.1 lib/with_filters/models/filter/filter.rb
with_filters-0.1.0 lib/with_filters/models/filter/filter.rb