Sha256: 7ab8b20c4b53893296d49b507bc6f60d5ee713aac6cdee1b967b72c08ecbd4c1

Contents?: true

Size: 1.25 KB

Versions: 154

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true
# typed: false

module T::Props::Plugin
  include T::Props
  extend T::Helpers

  module ClassMethods
    def included(child)
      super
      child.plugin(self)
    end
  end
  mixes_in_class_methods(ClassMethods)

  module Private
    # These need to be non-instance methods so we can use them without prematurely creating the
    # child decorator in `model_inherited` (see comments there for details).
    #
    # The dynamic constant access below forces this file to be `typed: false`
    def self.apply_class_methods(plugin, target)
      if plugin.const_defined?('ClassMethods')
        # FIXME: This will break preloading, selective test execution, etc if `mod::ClassMethods`
        # is ever defined in a separate file from `mod`.
        target.extend(plugin::ClassMethods) # rubocop:disable PrisonGuard/NoDynamicConstAccess
      end
    end

    def self.apply_decorator_methods(plugin, target)
      if plugin.const_defined?('DecoratorMethods')
        # FIXME: This will break preloading, selective test execution, etc if `mod::DecoratorMethods`
        # is ever defined in a separate file from `mod`.
        target.extend(plugin::DecoratorMethods) # rubocop:disable PrisonGuard/NoDynamicConstAccess
      end
    end
  end
end

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
sorbet-runtime-0.5.5909 lib/types/props/plugin.rb
sorbet-runtime-0.5.5903 lib/types/props/plugin.rb
sorbet-runtime-0.5.5898 lib/types/props/plugin.rb
sorbet-runtime-0.5.5895 lib/types/props/plugin.rb
sorbet-runtime-0.5.5891 lib/types/props/plugin.rb
sorbet-runtime-0.5.5890 lib/types/props/plugin.rb
sorbet-runtime-0.5.5888 lib/types/props/plugin.rb
sorbet-runtime-0.5.5883 lib/types/props/plugin.rb
sorbet-runtime-0.5.5881 lib/types/props/plugin.rb
sorbet-runtime-0.5.5880 lib/types/props/plugin.rb
sorbet-runtime-0.5.5879 lib/types/props/plugin.rb
sorbet-runtime-0.5.5878 lib/types/props/plugin.rb
sorbet-runtime-0.5.5877 lib/types/props/plugin.rb
sorbet-runtime-0.5.5873 lib/types/props/plugin.rb
sorbet-runtime-0.5.5871 lib/types/props/plugin.rb
sorbet-runtime-0.5.5870 lib/types/props/plugin.rb
sorbet-runtime-0.5.5869 lib/types/props/plugin.rb
sorbet-runtime-0.5.5868 lib/types/props/plugin.rb
sorbet-runtime-0.5.5867 lib/types/props/plugin.rb
sorbet-runtime-0.5.5866 lib/types/props/plugin.rb