Sha256: bf475bdb9b66f7141c6003bcdfa5e28ef43ff43d4f0ce0d57ca5e35c9fd5c099

Contents?: true

Size: 816 Bytes

Versions: 26

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/patches/class/common_constructor'

module EacRubyUtils
  module ModuleAncestorsVariable
    class Base
      common_constructor :the_module, :method_name, :initial_value

      # @param current [Object]
      # @param other [Object]
      # @return [Object]
      def merge_operation(current, other)
        current.merge(other)
      end

      # return [Hash]
      def ancestors_variable
        the_module.ancestors.inject(initial_value.dup) do |a, e|
          if e.respond_to?(method_name, true)
            merge_operation(a, e.send(method_name).send(:self_variable))
          else
            a
          end
        end
      end

      # @return [Hash]
      def self_variable
        @self_variable ||= initial_value.dup
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
eac_ruby_utils-0.123.0 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.121.0 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.120.0 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.76.1 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.76.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.75.2 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.119.2 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.75.1 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.75.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.119.1 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.74.1 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.74.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.73.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.119.0 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.72.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.118.1 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_ruby_utils-0.118.0 lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.70.1 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.70.0 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb
eac_tools-0.69.1 sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb