Sha256: 8ead96065ac97b89e52b3205d255830a0335f4cc9f602f095c886aae0093cf3d

Contents?: true

Size: 595 Bytes

Versions: 10

Compression:

Stored size: 595 Bytes

Contents

class Detour::FlaggableFlag < Detour::Flag
  include Detour::Concerns::CountableFlag

  belongs_to :flaggable, polymorphic: true

  validates_presence_of :flaggable

  attr_accessor   :flaggable_key
  attr_accessible :flaggable
  attr_accessible :flaggable_key

  before_validation :set_flaggable

  private

  def set_flaggable
    unless flaggable || !flaggable_key
      self.flaggable_id = flaggable_type.constantize.flaggable_find!(flaggable_key).id
    end
  rescue ActiveRecord::RecordNotFound
    errors.add(flaggable_type, "\"#{flaggable_key}\" could not be found")
    false
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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