Module: Dryopteris::RailsExtension
- Defined in:
- lib/dryopteris/rails_extension.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/dryopteris/rails_extension.rb', line 5 def self.included(base) base.extend(ClassMethods) # sets up default of stripping tags for all fields base.class_eval do before_save :sanitize_fields class_inheritable_reader :dryopteris_options end end |
Instance Method Details
#sanitize_fields ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dryopteris/rails_extension.rb', line 27 def sanitize_fields self.class.columns.each do |column| next unless (column.type == :string || column.type == :text) field = column.name.to_sym value = self[field] if && [:except].include?(field) next elsif && [:allow_tags].include?(field) self[field] = Dryopteris.sanitize(value) else self[field] = Dryopteris.(value) end end end |