Module: Postable::ClassMethods

Defined in:
lib/vendor/plugins/postable/lib/postable.rb

Instance Method Summary collapse

Instance Method Details

#marks_up(attribute) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vendor/plugins/postable/lib/postable.rb', line 8

def marks_up(attribute)
  before_validation "convert_#{attribute}_to_markdown".to_sym
  class_eval <<-EOC
    def convert_#{attribute}_to_markdown
      unless self.#{attribute}.blank?
        self.#{attribute}_html = RDiscount.new(#{attribute}).to_html
      end
    end
    private :convert_#{attribute}_to_markdown
  EOC
end

#slugifies(attribute) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vendor/plugins/postable/lib/postable.rb', line 20

def slugifies(attribute)
  before_validation "convert_#{attribute}_to_slug".to_sym
  class_eval <<-EOC
    def convert_#{attribute}_to_slug
      if self.#{attribute}_slug.blank?
        self.#{attribute}_slug = generate_slug(#{attribute})
      end
    end
    private :convert_#{attribute}_to_slug
  EOC
end