Sha256: 988f7721c6f3da9e350a55726d8d26b1e9b9abaee1089d36176c9cd60f5662a3

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

module ActsAsComment
  module InstanceMethods
	  # Before saving, store the comment label as as reply of the commentable label. This especially useful
	  # when representing context origin (i.e. a syndicated comment feed).
	  def auto_label
		  # Set up defaults and custom options (if any).
			options = self.class.acts_as_comment_options || {}
			options.reverse_merge! :commentable_label => "label", :comment_label => "label"
			# Default the comment label to the commentable label.
	    if self.instance_eval("self.#{options[:comment_label]}").blank? && commentable && commentable.respond_to?(options[:commentable_label])
				instance_eval("self.#{options[:comment_label]} = 'RE: ' + commentable.#{options[:commentable_label]}")
			end
	  end
  end 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aeonscope-acts_as_commentable-1.1.0 lib/instance_methods.rb