Module: Memoizer

Defined in:
lib/memoizer.rb,
lib/memoizer/version.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

VERSION =
'1.0.3'

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
# File 'lib/memoizer.rb', line 2

def self.included(base)
  base.extend ClassMethods
  base.send :include, InstanceMethods
end

.ivar_name(method_name) ⇒ Object



11
12
13
# File 'lib/memoizer.rb', line 11

def self.ivar_name(method_name)
  :"@_memoized_#{self.safe_name(method_name)}"
end

.safe_name(method_name) ⇒ Object



7
8
9
# File 'lib/memoizer.rb', line 7

def self.safe_name(method_name)
  method_name.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang').to_sym
end