Sha256: f43c28540bbf0e7a4d9300383fd4f81dd8e1368d72d8f6e6688281e2a18979cd
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
module ActsAsContentHighlightable module Model def acts_as_content_highlightable_on(column_name) if not self.column_names.include? column_name.to_s raise ArgumentError, "acts_as_content_highlightable_on: Invalid attribute #{column_name}" end class_eval do has_many :content_highlights, :as => :highlightable end class_eval %{ before_save :prepare_for_content_highlights, :if => :#{column_name.to_s}_changed? def highlightable_column return "#{column_name.to_s}" end def prepare_for_content_highlights self.#{column_name.to_s} = ActsAsContentHighlightable::HtmlNodeParser.new(self.#{column_name.to_s}).assign_unique_node_identifiers("data-" + ActsAsContentHighlightable.unique_html_node_identifier_key).body_content end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_content_highlightable-0.1.0 | lib/acts_as_content_highlightable/model.rb |