Module: Primer::Lazyness::Macros

Defined in:
lib/primer/lazyness.rb

Instance Method Summary collapse

Instance Method Details

#lazy_patch(*method_names) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/primer/lazyness.rb', line 12

def lazy_patch(*method_names)
  method_names.each do |method_name|
    instance_eval <<-RUBY
      alias :eager_#{method_name} :#{method_name}
      def #{method_name}(*args, &block)
        Primer::Lazyness::Proxy.new(self, primary_key, :eager_#{method_name}, args, block)
      end
    RUBY
  end
end