Sha256: 57b7312ca765f34482757f53f36fc36044be69bdd064cbdfb92346449ce8b24e

Contents?: true

Size: 586 Bytes

Versions: 10

Compression:

Stored size: 586 Bytes

Contents

# A group of flaggable records of a given class may be flagged into a feature
# with this class.
class Detour::DefinedGroupFlag < Detour::Flag
  include Detour::Concerns::Keepable

  validates_presence_of   :group_name
  validates_uniqueness_of :feature_id, scope: [:flaggable_type, :group_name]

  attr_accessible :group_name

  def group
    find_group || build_group
  end

  def group_type
    "defined"
  end

  private

  def find_group
    Detour::DefinedGroup.by_type(flaggable_type)[group_name]
  end

  def build_group
    Detour::DefinedGroup.new(group_name, ->{})
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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