Sha256: b793c68b9a387fe21a65e3377fe350e1dc07989086e5cbe53d7fa00ed1b6f57f

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

module PrivatePlease
  class Candidates
    def self.instance
      @@__instance ||= new
    end

    def self.reset_before_new_test
      @@__instance = nil
    end

    attr_reader :candidates, :inside_called_candidates, :outside_called_candidates
    def initialize
      @candidates                = Hash.new{ [] }
      @inside_called_candidates  = Hash.new{ [] }
      @outside_called_candidates = Hash.new{ [] }
    end

    def record_candidate(self_class, name)
      candidates[self_class.to_s] += Array(name)
    end

    def record_outside_call(self_class, name)
      #TODO use a Set instead of an Array
      unless outside_called_candidates[self_class.to_s].include?(name)
        outside_called_candidates[self_class.to_s] += Array(name)
      end
    end

    def record_inside_call(self_class, name)
      #TODO use a Set instead of an Array
      unless inside_called_candidates[self_class.to_s].include?(name)
        inside_called_candidates[self_class.to_s] += Array(name)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
private_please-0.0.2 lib/private_please/candidates.rb
private_please-0.0.1 lib/private_please/candidates.rb