Sha256: a1b983d548525f6b4ef20e6269d95176b865dde3c215d291dd346c1ce66a30e0

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

# As the main program runs, the various method calls are logged here
# (only for the methods marked with `private_please`)

module PrivatePlease
  module Storage

    class CallsStore

      def initialize
        @internal_calls       = MethodsNamesBucket.new
        @external_calls       = MethodsNamesBucket.new
        @class_internal_calls = MethodsNamesBucket.new
        @class_external_calls = MethodsNamesBucket.new
      end

    #--------------------------------------------------------------------------
    # QUERIES:
    #--------------------------------------------------------------------------

      attr_reader :internal_calls,
                  :external_calls,
                  :class_internal_calls,
                  :class_external_calls

    #--------------------------------------------------------------------------
    # COMMANDS:
    #--------------------------------------------------------------------------

      def store_outside_call(candidate)
        bucket = candidate.instance_method? ? external_calls : class_external_calls
        bucket.add_method_name(candidate.klass_name, candidate.method_name)
      end

      def store_inside_call(candidate)
        bucket = candidate.instance_method? ? internal_calls : class_internal_calls
        bucket.add_method_name(candidate.klass_name, candidate.method_name)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
private_please-0.0.5 lib/private_please/storage/calls_store.rb
private_please-0.0.4 lib/private_please/storage/calls_store.rb
private_please-0.0.3 lib/private_please/storage/calls_store.rb