Sha256: 40ffb123906fb36987574fd6334fc36ef918ba802e06a4764adfc3c46e068d8d
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Clevic class FilterCommand # filter_block will be passed a Dataset to filter. # filter_message will be displayed. def initialize( table_view, message = nil, &filter_block ) @table_view = table_view @message = message || 'filtered' @filter_block = filter_block end attr_reader :message # Do the filtering. Return true if successful, false otherwise. 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.message puts e.backtrace false end 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.13.0.b9 | lib/clevic/filter_command.rb |