File: lib/simpleton.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Simpleton#1
has properties
module method: included / 1 #3
  module: ClassMethods#7
has properties
method: instance / 1 #9
method: method_missing / 3 #15

Code

   1  module Simpleton
   2    
   3    def self.included(base)
   4      base.extend(ClassMethods)
   5    end
   6    
   7    module ClassMethods
   8      
   9      def instance(&block)
  10        @instance ||= new
  11        block.call(@instance) if block_given?
  12        @instance
  13      end
  14      
  15      def method_missing(method, *args, &block)
  16        instance.respond_to?(method) ? instance.send(method, *args, &block) : super
  17      end
  18      
  19    end
  20    
  21  en