Sha256: 20073710ef9ffca1bd01e66e8cef00a9be6524932d982ba1d5998e751b20f7b9

Contents?: true

Size: 872 Bytes

Versions: 7

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

# 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
        include FatFreeCRM::CommentExtensions::InstanceMethods unless included_modules.include?(InstanceMethods)
      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.include FatFreeCRM::CommentExtensions

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fat_free_crm-0.22.1 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.22.0 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.21.0 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.20.1 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.20.0 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.19.2 lib/fat_free_crm/comment_extensions.rb
fat_free_crm-0.19.0 lib/fat_free_crm/comment_extensions.rb