Sha256: 204548a2134ca2ad6d77110521e57dd033bad16cce5910e106f47c19dee0cfd7
Contents?: true
Size: 615 Bytes
Versions: 5
Compression:
Stored size: 615 Bytes
Contents
# frozen_string_literal: true # ## # # Ref: https://blog.appsignal.com/2018/10/02/ruby-magic-class-level-instance-variables.html module SknUtils module Wrappable def wrap(mod) wrappers << mod end def wrappers @wrappers ||= [] end def inherited_wrappers ancestors .grep(Wrappable) .reverse .flat_map(&:wrappers) end def new(*arguments, &block) instance = allocate inherited_wrappers.each { |mod|instance.singleton_class.include(mod) } instance.send(:initialize, *arguments, &block) instance end end end
Version data entries
5 entries across 5 versions & 1 rubygems