Module: HasWysiwygContent::Extensions::ClassMethods

Defined in:
lib/has_wysiwyg_content.rb

Instance Method Summary collapse

Instance Method Details

#has_wysiwyg_content(*fields) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/has_wysiwyg_content.rb', line 16

def has_wysiwyg_content(*fields)
  include HasWysiwygContent::Extensions::InstanceMethods

  const_set('WYSIWYG_FIELDS', fields.map(&:to_s))

  before_save {|o| cleanse_wysiwyg_content }

  define_method("self.class.wysiwyg_attributes") { (self.class.column_names & fields.map(&:to_s)) }
  class_eval <<-"EOV"
    class << self
      def wysiwyg_attributes
        column_names & WYSIWYG_FIELDS
      end
    end
  EOV
end