Sha256: 55d7d1e7208c82817a3db9c3ee14453e91c3a3fc266ddba52771607de7311b37

Contents?: true

Size: 533 Bytes

Versions: 1

Compression:

Stored size: 533 Bytes

Contents

require_dependency 'RedCloth'

module Models::MarkupConcern
  extend ActiveSupport::Concern

  class_methods do
    def markup(*args)
      args.extract_options!
      markup_attributes = *args
      markup_attributes.each do |attr|
        define_method attr do |format = :default|
          value = read_attribute(attr)
          case format
          when :html
            return unless value
            RedCloth.new(value).to_html.html_safe
          else
            value
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecm_videos-1.0.0 app/concerns/models/markup_concern.rb