Sha256: 77cacd9ed397f791c39d81dc4cf21d14e1c31df99eddb8bcad84971cd581dd02

Contents?: true

Size: 877 Bytes

Versions: 11

Compression:

Stored size: 877 Bytes

Contents

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module FatFreeCRM
  module CommentExtensions
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def uses_comment_extensions
        unless included_modules.include?(InstanceMethods)
          include FatFreeCRM::CommentExtensions::InstanceMethods
        end
      end
    end

    module InstanceMethods
      def add_comment_by_user(comment_body, user)
        comments.create(:comment => comment_body, :user => user) if comment_body.present?
      end
    end
  end
end

ActiveRecord::Base.send(:include, FatFreeCRM::CommentExtensions)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.5 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.4 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.3 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.2 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.12.3 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.12.2 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.1 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.12.1 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.13.0 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.12.0 lib/fat_free_crm/comment_extensions.rb