Class: Pakyow::Plugin::Lookup Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/pakyow/plugin/lookup.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(plugs) ⇒ Lookup

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Lookup.



13
14
15
# File 'lib/pakyow/plugin/lookup.rb', line 13

def initialize(plugs)
  @plugs = plugs
end

Instance Method Details

#finalizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pakyow/plugin/lookup.rb', line 17

def finalize
  @plugs.map { |plug|
    plug.class.plugin_name
  }.uniq.each do |plugin_name|
    define_singleton_method plugin_name do |plugin_instance_name = :default|
      plugin_instance_name = plugin_instance_name.to_sym

      @plugs.find { |plug|
        plug.class.plugin_name == plugin_name && plug.__object_name.namespace.parts.last == plugin_instance_name
      }
    end
  end
end