Module: Covercache::DefiningHelper

Defined in:
lib/covercache.rb

Overview

Defining Helper

Instance Method Summary collapse

Instance Method Details

#class_define_cached(method, *args, &block) ⇒ Object



152
153
154
155
156
157
# File 'lib/covercache.rb', line 152

def class_define_cached(method, *args, &block)
  options = args.extract_options!
  options[:is_class_method] = true
  args << options
  self.send :define_cached, method, *Array.wrap(args), &block
end

#define_cached(method, *args, &block) ⇒ Object

Define and wrap methods or blocks



141
142
143
144
145
146
147
148
149
150
# File 'lib/covercache.rb', line 141

def define_cached(method, *args, &block)
  options = args.extract_options!
  is_class_method = !!options.delete(:is_class_method)

  file, line = caller[is_class_method ? 1 : 0].split ':', 2
  line = line.to_i
  
  covercache_method_arguments method, args, options, &block
  covercache_define_wrapper method, file, line, is_class_method
end