Sha256: 39d377beb558bfd27302dfb49eac28acf528bde1b46c09bec37254f3b26985ac
Contents?: true
Size: 852 Bytes
Versions: 4
Compression:
Stored size: 852 Bytes
Contents
# frozen_string_literal: true require_relative 'coaction' module Coactive module Coactions extend ActiveSupport::Concern class << self class_attribute :registry self.registry = {} def [](base, name) registry.dig(base, name) end def []=(base, name, array) registry[base] ||= {} registry[base][name] = array end end class_methods do def coaction(*names, **options) base = coactive_config.base_class names.each do |name| coaction = Coaction.new(self, name, options) coaction.priority ||= coactive_config.default_priority coactions = (Coactions[base, name].to_a + [coaction]) Coactions[base, name] = coactions.sort_by.with_index { |coaction, i| [coaction.priority, i] } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
coactive-0.6.0 | lib/coactive/coactions.rb |
coactive-0.5.2 | lib/coactive/coactions.rb |
coactive-0.5.1 | lib/coactive/coactions.rb |
coactive-0.5.0 | lib/coactive/coactions.rb |