Module: SmartIgnoredColumns::Extension
- Defined in:
- lib/smart_ignored_columns/extension.rb
Overview
Includes extension of the ‘ignored_columns=` method.
Instance Method Summary collapse
-
#ignored_columns=(columns) ⇒ Object
Extension of the default ‘ignored_columns=` method with an ability to specify deadlines.
- #smart_ignored_columns ⇒ Object
- #smart_ignored_columns=(columns) ⇒ Object
Instance Method Details
#ignored_columns=(columns) ⇒ Object
Extension of the default ‘ignored_columns=` method with an ability to specify deadlines.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/smart_ignored_columns/extension.rb', line 17 def ignored_columns=(columns) columns = columns.flatten all_columns_valid = columns.all? do |column| column.is_a?(Hash) && column.key?(:name) && column.key?(:remove_after) end unless all_columns_valid raise ArgumentError, "columns should be an array of hashes, each containing :name and :remove_after options" end super(columns.pluck(:name)) self.smart_ignored_columns += columns.map do |column| IgnoredColumn.new(column[:name], column[:remove_after]) end end |
#smart_ignored_columns ⇒ Object
36 37 38 |
# File 'lib/smart_ignored_columns/extension.rb', line 36 def smart_ignored_columns @smart_ignored_columns || superclass.try(:smart_ignored_columns) || [] end |
#smart_ignored_columns=(columns) ⇒ Object
41 42 43 |
# File 'lib/smart_ignored_columns/extension.rb', line 41 def smart_ignored_columns=(columns) @smart_ignored_columns = columns end |