Module: AutoStripAttributes
- Defined in:
- lib/auto_strip_attributes.rb,
lib/auto_strip_attributes/version.rb
Defined Under Namespace
Classes: Config
Constant Summary collapse
- VERSION =
"2.0.5"
Instance Method Summary collapse
Instance Method Details
#auto_strip_attributes(*attributes) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/auto_strip_attributes.rb', line 4 def auto_strip_attributes(*attributes) = AutoStripAttributes::Config.filters_enabled if attributes.last.is_a?(Hash) = .merge(attributes.pop) end attributes.each do |attribute| before_validation do |record| #debugger value = record[attribute] AutoStripAttributes::Config.filters_order.each do |filter_name| next unless [filter_name] value = AutoStripAttributes::Config.filters[filter_name].call value record[attribute] = value end end end end |