Create a new memoized method

 @return [undefined]

 @api private
3341
def create_memoized_method
      name, method, freezer = @method_name, @original_method, @freezer
      @descendant.module_eval do
        define_method(name) do |&block|
          fail BlockNotAllowedError.new(self.class, name) if block
          memoized_method_cache.fetch(name) do
            freezer.call(method.bind(self).call)
          end
        end
      end
    end
1121535
def method_missing(name, *args, &block)
      if self.class.resources.keys.include?(name)
        resources[name] ||= self.class.resources[name].new(self)
        resources[name]
      else
        super
      end
    end
55447
def method_for_cached(object, key, fetch_method=:fetch, method_name=nil)
      method_name = ("cached_" + (method_name || key)).gsub(/[^\w\!\?]/, '_')
      method_body = <<-END
        def #{method_name}(*args, &block)
          opts = args.empty? ? {} : args.first

          proxy = AridCache::CacheProxy.new(self, #{key.inspect}, opts, &block)
          if opts[:clear] == true
            proxy.clear_cached
          else
            proxy.#{fetch_method.to_s}
          end
        end
      END
      # Get the correct object
      object = (class << object; self; end) if object.is_a?(Class)
      object.class_eval(method_body, __FILE__, __LINE__)
    end
876770
def create_migration_method_hashes
      # the class => attribute => migration filter hash
      @attr_flt_hash = {}
      customizable_class_attributes.each do |klass, pas|
        flts = migration_filters(klass) || next
        @attr_flt_hash[klass] = flts
      end
      # print the migration shim methods
      unless @mgt_mths.empty? then
        logger.info("Migration shim methods:\n#{@mgt_mths.qp}")
      end
    end
1333055
function memoized() {
          if (!lastArguments) {
              lastResult = projectionFn.apply(null, arguments);
              lastArguments = arguments;
              return lastResult;
          }
          if (!isArgumentsChanged(arguments, lastArguments, isArgumentsEqual)) {
              return lastResult;
          }
          lastArguments = arguments;
          var newResult = projectionFn.apply(null, arguments);
          if (isResultEqual(lastResult, newResult)) {
              return lastResult;
          }
          lastResult = newResult;
          return newResult;
      }
713853
function(methods) {
    var keys = Object.keys(methods);
    var len = keys.length;
    for (var i = 0; i < len; i++) {
      var key = keys[i];
      this[key] = lib.method.createMethod(methods[key]);
    }
    return factory;
  }
34971
def slice(*methods)
      Hash[methods.map! { |method| [method, public_send(method)] }].with_indifferent_access
    end
1049660
def method_missing(name, *args)
      copy = self.dup
      copy.instance_eval { @args << [name, *(args.collect { |a| a.to_s })] }
      copy
    end
814392
def memoized(maxsize=1024):
    
    cache = SimpleCache(maxsize=maxsize)

    def decorator(obj):
        @wraps(obj)
        def new_callable(*a, **kw):
            def create_new():
                return obj(*a, **kw)

            key = (a, tuple(kw.items()))
            return cache.get(key, create_new)
        return new_callable
    return decorator
315758
def create_new_spec(class_or_module, dry_run, rails_mode, file_path, spec_path)
      # These names are used in ERB template, don't delete.
      # rubocop:disable Lint/UselessAssignment
      methods_to_generate = class_or_module.method_list.select { |m| m.visibility == :public }
      c = class_or_module
      self_path = to_string_value_to_require(file_path)
      # rubocop:enable Lint/UselessAssignment

      erb = RSpecKickstarter::ERBFactory.new(@full_template).get_instance_for_new_spec(rails_mode, file_path)
      code = erb.result(binding)

      if dry_run
        puts "----- #{spec_path} -----"
        puts code
      else
        if File.exist?(spec_path)
          puts "#{spec_path} already exists."
        else
          FileUtils.mkdir_p(File.dirname(spec_path))
          File.open(spec_path, 'w') { |f| f.write(code) }
          puts "#{spec_path} created."
        end
      end
    end
262057
def build_ansi_methods(hash)
      hash.each do |key, value|

        define_method(key) do |string=nil, &block|
          result = Array.new

          result << %(\e[#{value}m)
          if block_given?
            result << block.call
          elsif string.respond_to?(:to_str)
            result << string.to_str
          elsif respond_to?(:to_str)
            result << to_str
          else
            return result
          end
          result << %(\e[0m)

          result.join
        end
      end

      true
    end
57221
def create_versions_hash
      hash = Hash.new { |h, k| h[k] = [] }

      versions.each do |version|
        hash[version[0]] << version
      end

      hash
    end
1285001
def add_method(instance, method_name)
      define_singleton_method(method_name) do |*args|
        instance.public_send(method_name, *args)
      end
    end
558890
def create_methods_from_instance(instance)
      instance.public_methods(false).each do |method_name|
        add_method(instance, method_name)
      end
    end
1368103
def memorize(func):
    
    @wraps(func)
    def wrapped_func(*args, **kwargs):
        if (len(args) > 0 and len(kwargs) > 0): 
            cacheKey = list(args)
            cacheKey.append(kwargs)
        elif (len(args) > 0): 
            cacheKey = args
        else:
            cacheKey = func.__name__
            
        global __cache__
        result = __cache__.get(cacheKey)
        if result is None:
            result = func(*args, **kwargs)
            __cache__[cacheKey] = result
        return result

    return wrapped_func
279602
def create_headline_methods
      api_resources.each do |k,v|
        define_singleton_method(k) do |opt=nil|
          get_results(v[:url], get_api_method(opt))
        end
      end
    end
493859
def memoize(f):
    
    cache = {}

    @wraps(f)
    def inner(arg):
        if arg not in cache:
            cache[arg] = f(arg)
        return cache[arg]
    return inner