Sha256: 12a458831bb6609816d1db55745367834b6acdab2731d5605e3a2083c701bed1

Contents?: true

Size: 719 Bytes

Versions: 32

Compression:

Stored size: 719 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveRecord
      # @private
      module Uniqueness
        # @private
        class Namespace
          def initialize(constant)
            @constant = constant
          end

          def has?(name)
            constant.const_defined?(name)
          end

          def set(name, value)
            constant.const_set(name, value)
          end

          def clear
            constant.constants.each do |child_constant|
              constant.__send__(:remove_const, child_constant)
            end
          end

          def to_s
            constant.to_s
          end

          protected

          attr_reader :constant
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.4.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb