Class: Clevic::FilterCommand
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#doit ⇒ Object
Do the filtering.
-
#initialize(table_view, message = nil, &filter_block) ⇒ FilterCommand
constructor
filter_block will be passed a Dataset to filter.
- #undo ⇒ Object
Constructor Details
#initialize(table_view, message = nil, &filter_block) ⇒ FilterCommand
filter_block will be passed a Dataset to filter. filter_message will be displayed.
5 6 7 8 9 |
# File 'lib/clevic/filter_command.rb', line 5 def initialize( table_view, = nil, &filter_block ) @table_view = table_view @message = || 'filtered' @filter_block = filter_block end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/clevic/filter_command.rb', line 11 def @message end |
Instance Method Details
#doit ⇒ Object
Do the filtering. Return true if successful, false otherwise.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/clevic/filter_command.rb', line 14 def doit # store current dataset @previous_dataset = @table_view.model.cache_table.dataset # store auto_new @auto_new = @table_view.model.auto_new # reload cache table with new conditions @table_view.model.auto_new = false @table_view.model.reload_data( &@filter_block ) true rescue Exception => e puts puts e. puts e.backtrace false end |
#undo ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/clevic/filter_command.rb', line 32 def undo # restore auto_new @table_view.model.auto_new = @auto_new # reload cache table with stored AR conditions @table_view.model.reload_data( @previous_dataset ) end |