Sha256: 245f1047357eb51d1ff4a312f6bce8ad5c454f2c33aeffe2d87f67f5b06822ae
Contents?: true
Size: 1.56 KB
Versions: 27
Compression:
Stored size: 1.56 KB
Contents
# encoding: UTF-8 module Wice class GridOutputBuffer < String #:nodoc: attr_reader :stubborn_output_mode attr_accessor :return_empty_strings_for_nonexistent_filters def stubborn_output_mode=(m) RAILS_DEFAULT_LOGGER.debug("=== WiceGrid: detached filters are requested, postponing output till the second call of the view helper") if m @stubborn_output_mode = m end def initialize(*attrs) super(*attrs) @filters = HashWithIndifferentAccess.new @first_output = false @stubborn_output_mode = false end def to_s if @first_output || ! @stubborn_output_mode super.html_safe_if_necessary else @first_output = true '' end end def add_filter(detach_with_id, filter_code) raise WiceGridException.new("Detached ID #{detach_with_id} is already used!") if @filters.has_key? detach_with_id @filters[detach_with_id] = filter_code end def filter_for detach_with_id unless @filters.has_key? detach_with_id if @return_empty_strings_for_nonexistent_filters return '' else raise WiceGridException.new("No filter with Detached ID '#{detach_with_id}'!") end end raise WiceGridException.new("Filter with Detached ID '#{detach_with_id}' has already been requested once! There cannot be two instances of the same filter on one page") if @filters[detach_with_id] == false res = @filters[detach_with_id] @filters[detach_with_id] = false return res end alias_method :[], :filter_for end end
Version data entries
27 entries across 27 versions & 4 rubygems