Sha256: a1533a909bb031752ecf55168c1b5dd0ba36072b875a4d96ea59cf53bfdccf04
Contents?: true
Size: 731 Bytes
Versions: 6
Compression:
Stored size: 731 Bytes
Contents
# frozen_string_literal: true module Coactive module Coactants extend ActiveSupport::Concern included do class_attribute :_coactants self._coactants = [] end class_methods do def coact(*coactants, **options, &block) if block self._coactants = _coactants + [block] elsif options[:before] index = self._coactants.index { |coactant| coactant == options[:before] } self._coactants = self._coactants.insert(index, *coactants) else self._coactants = _coactants + coactants end end def coactants self._coactants end def clear_coactants self._coactants = [] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems