Class: Wice::GridOutputBuffer
- Defined in:
- lib/wice/grid_output_buffer.rb
Overview
:nodoc:
Instance Attribute Summary collapse
- 
  
    
      #return_empty_strings_for_nonexistent_filters  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    defines behavior for rendering nonexistent filters. 
Instance Method Summary collapse
- 
  
    
      #add_filter(detach_with_id, filter_code)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    stores HTML code for a detached filter. 
- 
  
    
      #filter_for(detach_with_id)  ⇒ Object 
    
    
      (also: #[])
    
  
  
  
  
  
  
  
  
  
    returns HTML code for a detached filter. 
- 
  
    
      #initialize(*attrs)  ⇒ GridOutputBuffer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    initializes a grid output buffer. 
- #inspect ⇒ Object
- 
  
    
      #to_s  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns HTML code the grid. 
Constructor Details
#initialize(*attrs) ⇒ GridOutputBuffer
initializes a grid output buffer
| 10 11 12 13 | # File 'lib/wice/grid_output_buffer.rb', line 10 def initialize(*attrs) super(*attrs) @filters = HashWithIndifferentAccess.new end | 
Instance Attribute Details
#return_empty_strings_for_nonexistent_filters ⇒ Object
defines behavior for rendering nonexistent filters. If return_empty_strings_for_nonexistent_filters is true, a call to render a non existent filter will raise an exception If return_empty_strings_for_nonexistent_filters is false (CSV mode), no exception will be raised.
| 7 8 9 | # File 'lib/wice/grid_output_buffer.rb', line 7 def return_empty_strings_for_nonexistent_filters @return_empty_strings_for_nonexistent_filters end | 
Instance Method Details
#add_filter(detach_with_id, filter_code) ⇒ Object
stores HTML code for a detached filter
| 25 26 27 28 | # File 'lib/wice/grid_output_buffer.rb', line 25 def add_filter(detach_with_id, filter_code) raise WiceGridException.new("Detached ID #{detach_with_id} is already used!") if @filters.key? detach_with_id @filters[detach_with_id] = filter_code end | 
#filter_for(detach_with_id) ⇒ Object Also known as: []
returns HTML code for a detached filter
| 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # File 'lib/wice/grid_output_buffer.rb', line 31 def filter_for(detach_with_id) unless @filters.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 unless @filters[detach_with_id] 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") end res = @filters[detach_with_id] @filters[detach_with_id] = false res end | 
#inspect ⇒ Object
| 15 16 17 | # File 'lib/wice/grid_output_buffer.rb', line 15 def inspect "#<Wice::GridOutputBuffer #{@filters.map{|key, filter| "#{key}: #{filter.inspect}"}.join ', '}>" end | 
#to_s ⇒ Object
returns HTML code the grid
| 20 21 22 | # File 'lib/wice/grid_output_buffer.rb', line 20 def to_s super.html_safe end |