Module: Loki::Identity

Included in:
Task::File, Task::Task
Defined in:
lib/loki/identity.rb

Class Method Summary collapse

Class Method Details

.included(other) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/loki/identity.rb', line 6

def self.included(other)
  other.class_eval %{
    class << self
      alias_method :__#{other.to_s.gsub(':','')}_new, :new
      def new(name, *args, &block)
        name = self.identify(name) if self.respond_to?(:identify)
        IDENTITY_MAP.fetch(name) do
          IDENTITY_MAP[name] = __#{other.to_s.gsub(':','')}_new(name, *args, &block)
        end
      end
    end
  }
end