Sha256: 6f7f8e0eb48073990332976e9a03b56b8e3034334ae561c5d2eab500f0c47cbf

Contents?: true

Size: 366 Bytes

Versions: 4

Compression:

Stored size: 366 Bytes

Contents

class << ActiveRecord::Base

  def converts_markdown(markdown = :markdown, html = :html)
    markdown = markdown.to_s
    html = html.to_s

    after_save :"convert_#{markdown}_to_#{html}"

    define_method "convert_#{markdown}_to_#{html}" do
      update_columns(
        html.to_sym => MarkItZero::Markdown.to_html(self.send(markdown))
      )
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mark_it_zero-0.3.2 lib/mark_it_zero/converts_markdown.rb
mark_it_zero-0.3.1 lib/mark_it_zero/converts_markdown.rb
mark_it_zero-0.3.0 lib/mark_it_zero/converts_markdown.rb
mark_it_zero-0.2.0 lib/mark_it_zero/converts_markdown.rb