Sha256: 8146ad66bc6a4ce9d3122b7037d75ad1fe5ad3f4b1cfc656cff64b87e45e95fa

Contents?: true

Size: 674 Bytes

Versions: 9

Compression:

Stored size: 674 Bytes

Contents

class Detour::DatabaseGroupFlag < Detour::Flag
  include Detour::Concerns::Keepable

  validates_presence_of   :group_id
  validates_presence_of   :flaggable_type
  validates_uniqueness_of :feature_id, scope: :group_id

  attr_accessible :group_id

  belongs_to :group
  has_many   :memberships, through: :group

  def members
    flaggable_class.joins(%Q{INNER JOIN "detour_memberships" ON "#{flaggable_class.table_name}"."id" = "detour_memberships"."member_id"}).where(detour_memberships: { group_id: group.id })
  end

  def group_name
    group.name
  end

  def group_type
    "database"
  end

  private

  def flaggable_class
    flaggable_type.constantize
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
detour-0.0.15 app/models/detour/database_group_flag.rb
detour-0.0.14 app/models/detour/database_group_flag.rb
detour-0.0.13 app/models/detour/database_group_flag.rb
detour-0.0.12 app/models/detour/database_group_flag.rb
detour-0.0.11 app/models/detour/database_group_flag.rb
detour-0.0.10 app/models/detour/database_group_flag.rb
detour-0.0.9 app/models/detour/database_group_flag.rb
detour-0.0.7 app/models/detour/database_group_flag.rb
detour-0.0.6 app/models/detour/database_group_flag.rb