Sha256: 924f248c0adb9a977327c415476b1de5d1da098af00afec4d0d4f500152d9caf

Contents?: true

Size: 545 Bytes

Versions: 7

Compression:

Stored size: 545 Bytes

Contents

module Usable
  class Config < OpenStruct
    def modules
      @modules ||= []
    end

    def add_module(mod)
      modules << mod
    end

    def available_methods
      modules.each_with_object(Hash.new(default_method)) do |mod, result|
        mod.instance_methods.each do |method_name|
          result[method_name] = mod.instance_method method_name
        end
      end
    end

    def default_method
      Null.instance_method(:default_method)
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
usable-1.4.0 lib/usable/config.rb
usable-1.3.1 lib/usable/config.rb
usable-1.3.0 lib/usable/config.rb
usable-1.2.1 lib/usable/config.rb
usable-1.2.0 lib/usable/config.rb
usable-1.1.1 lib/usable/config.rb
usable-1.1.0 lib/usable/config.rb