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.
-
#to_s ⇒ Object
returns HTML code the grid.
Constructor Details
#initialize(*attrs) ⇒ GridOutputBuffer
initializes a grid output buffer
11 12 13 14 |
# File 'lib/wice/grid_output_buffer.rb', line 11 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.
8 9 10 |
# File 'lib/wice/grid_output_buffer.rb', line 8 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
22 23 24 25 |
# File 'lib/wice/grid_output_buffer.rb', line 22 def add_filter(detach_with_id, filter_code) fail 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wice/grid_output_buffer.rb', line 28 def filter_for(detach_with_id) unless @filters.key? detach_with_id if @return_empty_strings_for_nonexistent_filters return '' else fail WiceGridException.new("No filter with Detached ID '#{detach_with_id}'!") end end unless @filters[detach_with_id] fail 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 |
#to_s ⇒ Object
returns HTML code the grid
17 18 19 |
# File 'lib/wice/grid_output_buffer.rb', line 17 def to_s super.html_safe end |