Sha256: 7d878b0ceb95beef0c2857b92d671c99969de88dfad53d0c8097ef0c1be4793b
Contents?: true
Size: 891 Bytes
Versions: 62
Compression:
Stored size: 891 Bytes
Contents
module Workarea module Commentable extend ActiveSupport::Concern included do field :subscribed_user_ids, type: Array, default: [] has_many :comments, class_name: 'Workarea::Comment', as: :commentable before_save do subscribed_user_ids.map!(&:to_s).map!(&:downcase) if subscribed_user_ids.present? end end def add_subscription(list) all = subscribed_user_ids + clean_subscription_list(list) update_attribute(:subscribed_user_ids, all.uniq) end def remove_subscription(list) update_attribute( :subscribed_user_ids, subscribed_user_ids - clean_subscription_list(list) ) end private def clean_subscription_list(list) list = list.join(',') if list.respond_to?(:join) list.to_s.split(',').map(&:strip).map(&:downcase).reject(&:blank?) end end end
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
workarea-core-3.4.13 | app/models/workarea/commentable.rb |
workarea-core-3.4.12 | app/models/workarea/commentable.rb |