Sha256: c3af20d68d461aabdabec03cc7f6aed562b4611b9d5319993262e6eb3fc76eed

Contents?: true

Size: 891 Bytes

Versions: 6

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/module/introspection'
require 'eac_ruby_utils/patches/class/common_constructor'
require 'eac_ruby_utils/patches/module/common_concern'
require 'eac_ruby_utils/patches/module/module_parent'
require 'eac_ruby_utils/patches/string/inflector'

module EacRubyUtils
  module MethodClass
    common_concern do
      ::EacRubyUtils::MethodClass::Setup.new(self)
    end

    class Setup
      common_constructor :method_class do
        perform
      end

      def perform
        the_setup = self
        sender_module.define_method(method_name) do |*args, &block|
          the_setup.method_class.new(self, *args, &block).result
        end
      end

      def method_name
        method_class.name.demodulize.underscore.variableize
      end

      def sender_module
        method_class.module_parent
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
eac_tools-0.31.0 sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb
eac_tools-0.30.0 sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb
eac_tools-0.29.0 sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb
eac_ruby_utils-0.103.0 lib/eac_ruby_utils/method_class.rb
eac_tools-0.28.0 sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb
eac_ruby_utils-0.102.1 lib/eac_ruby_utils/method_class.rb