Sha256: ad650525b746b37b7e0921061a954fb560cd30057dc536fc2553d998957dd53b

Contents?: true

Size: 573 Bytes

Versions: 20

Compression:

Stored size: 573 Bytes

Contents

module Usable
  # Keep track of "used" modules and their "available" methods
  # Mixin for Config
  module ConfigRegister
    def available_methods
      modules.each_with_object(Hash.new(Null.instance_method(:default_method))) do |mod, result|
        mod.instance_methods.each do |method_name|
          result[method_name] = mod.instance_method method_name
        end
      end
    end

    def add_module(mod)
      modules << mod
    end

    def modules
      @modules ||= []
    end

    module Null
      def default_method(*, &_block)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
usable-3.10.0 lib/usable/config_register.rb
usable-3.9.4 lib/usable/config_register.rb
usable-3.9.3 lib/usable/config_register.rb
usable-3.9.2 lib/usable/config_register.rb
usable-3.9.1 lib/usable/config_register.rb
usable-3.9.0 lib/usable/config_register.rb
usable-3.8.0 lib/usable/config_register.rb
usable-3.7.1 lib/usable/config_register.rb
usable-3.7.0 lib/usable/config_register.rb
usable-3.6.2 lib/usable/config_register.rb
usable-3.6.1 lib/usable/config_register.rb
usable-3.6.0 lib/usable/config_register.rb
usable-3.5.0 lib/usable/config_register.rb
usable-3.4.0 lib/usable/config_register.rb
usable-3.3.0 lib/usable/config_register.rb
usable-3.2.0 lib/usable/config_register.rb
usable-3.1.0 lib/usable/config_register.rb
usable-3.0.0 lib/usable/config_register.rb
usable-2.2.1 lib/usable/config_register.rb
usable-2.2.0 lib/usable/config_register.rb