Sha256: 7aba97c8043fb95e00e731a8405867d029778f194e05699242838e965000a5d2

Contents?: true

Size: 457 Bytes

Versions: 12

Compression:

Stored size: 457 Bytes

Contents

module Detour::Concerns
  module CountableFlag
    extend ActiveSupport::Concern

    included do
      after_save    :step_count
      after_destroy :step_count

      private

      def step_count
        count = feature.send("#{flag_type}_count_for", flaggable_type.tableize)
        count = destroyed? ? count - 1 : count + 1
        feature.send("#{flag_type}_counts")[flaggable_type.tableize] = count
        feature.save!
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
detour-0.0.15 app/models/detour/concerns/countable_flag.rb
detour-0.0.14 app/models/detour/concerns/countable_flag.rb
detour-0.0.13 app/models/detour/concerns/countable_flag.rb
detour-0.0.12 app/models/detour/concerns/countable_flag.rb
detour-0.0.11 app/models/detour/concerns/countable_flag.rb
detour-0.0.10 app/models/detour/concerns/countable_flag.rb
detour-0.0.9 app/models/detour/concerns/countable_flag.rb
detour-0.0.7 app/models/detour/concerns/countable_flag.rb
detour-0.0.6 app/models/detour/concerns/countable_flag.rb
detour-0.0.5 app/models/detour/concerns/countable_flag.rb
detour-0.0.3 app/models/detour/concerns/countable_flag.rb
detour-0.0.2 app/models/detour/concerns/countable_flag.rb