Sha256: 5f277a21372f3a74d75aeb41efa8065233aaf8996765e5457de0218e1c467265

Contents?: true

Size: 460 Bytes

Versions: 3

Compression:

Stored size: 460 Bytes

Contents

# Fetch the definition for a counter
# counter.definition # => Counter::Definition
module Counter::Definable
  extend ActiveSupport::Concern

  included do
    # Fetch the definition for this counter
    def definition
      if parent.nil?
        # We don't have a parent, so we're a global counter
        Counter::Definition.find_definition name
      else
        parent.class.counter_configs.find { |c| c.record_name == name }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
counterwise-0.1.2 app/models/concerns/counter/definable.rb
counterwise-0.1.1 app/models/concerns/counter/definable.rb
counterwise-0.1.0 app/models/concerns/counter/definable.rb