Sha256: 1039b852fe617edabf490f7e01f0c609c1bea938061e1bb9d80b34cc33193562

Contents?: true

Size: 795 Bytes

Versions: 19

Compression:

Stored size: 795 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

19 entries across 19 versions & 1 rubygems

Version Path
message_train-0.6.17 spec/dummy/app/models/group.rb
message_train-0.6.16 spec/dummy/app/models/group.rb
message_train-0.6.15 spec/dummy/app/models/group.rb
message_train-0.6.14 spec/dummy/app/models/group.rb
message_train-0.6.13 spec/dummy/app/models/group.rb
message_train-0.6.12 spec/dummy/app/models/group.rb
message_train-0.6.11 spec/dummy/app/models/group.rb
message_train-0.6.10 spec/dummy/app/models/group.rb
message_train-0.6.9 spec/dummy/app/models/group.rb
message_train-0.6.8 spec/dummy/app/models/group.rb
message_train-0.6.7 spec/dummy/app/models/group.rb
message_train-0.6.6 spec/dummy/app/models/group.rb
message_train-0.6.5 spec/dummy/app/models/group.rb
message_train-0.6.4 spec/dummy/app/models/group.rb
message_train-0.6.3 spec/dummy/app/models/group.rb
message_train-0.6.2 spec/dummy/app/models/group.rb
message_train-0.6.1 spec/dummy/app/models/group.rb
message_train-0.6.0 spec/dummy/app/models/group.rb
message_train-0.5.3 spec/dummy/app/models/group.rb