27 Sep '14, 6pm

@maurogeorge

# include InstanceMethods # if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type) raise "Already memoized #{symbol}" # raise "Already memoized mime_type" end # end alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type # if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0 def #{symbol}(reload = false) # def mime_type(reload = false) if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty? #{memoized_ivar} = [#{original_method}] # @_memoized_mime_type = [_unmemoized_mime_type] end # end #{memoized_ivar}[0] # @_memoized_mime_type[0] end # end else # else def #{symbol}(*args) # def mime_type(*args) #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen? args_length = method(:#{...

Full article: http://apidock.com/rails/v3.2.13/ActiveSupport/Memoizable...

Tweets