Sha256: 0af1deb65ebb2ff9c503518b27d5f33907f0dc5b5af89d38dcde7c46dd4dd136
Contents?: true
Size: 623 Bytes
Versions: 3
Compression:
Stored size: 623 Bytes
Contents
module WithFilters module Filter # @private class Select < Base def initialize(name, namespace, value, options = {}) collection = options.delete(:collection) if options[:collection].is_a?(String) if collection Array.wrap(value).each do |v| matched = collection.sub!(/(<option[^>]*value\s*=\s*['"]?#{v}[^>]*)/, '\1 selected="selected"') unless matched collection.sub!(/>#{v}</, " selected=\"selected\">#{v}<") end end end super @collection = collection if collection end 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/select.rb |
with_filters-0.1.1 | lib/with_filters/models/filter/select.rb |
with_filters-0.1.0 | lib/with_filters/models/filter/select.rb |