Sha256: c5c3ff6235beebbf1d3bbe67281a22fdae3bb0d342fde006fe62946069477f3d

Contents?: true

Size: 794 Bytes

Versions: 25

Compression:

Stored size: 794 Bytes

Contents

class Group < ActiveRecord::Base
  # Rolify Gem
  resourcify

  # MessageTrain Gem
  message_train only: :recipient,
                valid_senders: :owners,
                name_column: :title,
                slug_column: :slug,
                collectives_for_recipient: :membered_by,
                valid_recipients: :recipients

  # Callbacks
  before_create :set_slug

  scope :membered_by, ->(user) { with_roles([:member, :owner], user).uniq }

  def set_slug
    # Manually generate slug instead of using friendly id, for testing.
    self.slug = title.downcase.gsub(/[^a-z0-9]+/, '-')
  end

  def owners
    User.with_role(:owner, self)
  end

  def recipients
    User.with_role(:member, self)
  end

  def self.fallback_address_book(user)
    Group.with_role(:owner, user)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
message_train-0.5.2 spec/dummy/app/models/group.rb
message_train-0.5.1 spec/dummy/app/models/group.rb
message_train-0.5.0 spec/dummy/app/models/group.rb
message_train-0.4.6 spec/dummy/app/models/group.rb
message_train-0.4.5 spec/dummy/app/models/group.rb
message_train-0.4.4 spec/dummy/app/models/group.rb
message_train-0.4.3 spec/dummy/app/models/group.rb
message_train-0.4.2 spec/dummy/app/models/group.rb
message_train-0.4.1 spec/dummy/app/models/group.rb
message_train-0.4.0 spec/dummy/app/models/group.rb
message_train-0.3.1 spec/dummy/app/models/group.rb
message_train-0.3.0 spec/dummy/app/models/group.rb
message_train-0.2.12 spec/dummy/app/models/group.rb
message_train-0.2.11 spec/dummy/app/models/group.rb
message_train-0.2.10 spec/dummy/app/models/group.rb
message_train-0.2.9 spec/dummy/app/models/group.rb
message_train-0.2.8 spec/dummy/app/models/group.rb
message_train-0.2.7 spec/dummy/app/models/group.rb
message_train-0.2.6 spec/dummy/app/models/group.rb
message_train-0.2.5 spec/dummy/app/models/group.rb