Method: Flyweight#initialize

Defined in:
lib/exegesis/flyweight.rb

#initialize(&key_processor) ⇒ Flyweight

Create an empty Flyweight with the given key-processing proc.

Parameters:

  • key_processor (Proc)

    a proc which turns an instance into it’s key.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/exegesis/flyweight.rb', line 19

def initialize(&key_processor)
  clear!

  if block_given?
    @key_processor = key_processor
  else
    @key_processor = proc { |id| id }
  end

  self
end