module HtmlTerminator::ClassMethods
Public Instance Methods
fields()
click to toggle source
# File lib/html_terminator.rb, line 21 def fields self.columns.inject([]) do |list, col| if col.type == :string or col.type == :text list << col.name.to_sym end list end end
terminate_html(*args)
click to toggle source
Calls superclass method
# File lib/html_terminator.rb, line 31 def terminate_html(*args) # Table may not exist yet when schema is initially getting loaded if self.table_exists? # object key/value of field => options unless method_defined?(:html_terminator_fields) class_attribute :html_terminator_fields self.html_terminator_fields = {} end options = args.extract_options! options = SANITIZE_OPTIONS.clone.merge(options) valid_fields = self.fields & args valid_fields.each do |field| self.html_terminator_fields[field] = options.deep_dup end unless self.html_terminator_fields.empty? before_validation :terminate_html # sanitize reads valid_fields.each do |attr| define_method(attr) do |*rargs| # sanitize it HtmlTerminator.sanitize super(*rargs), options end end end end end