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-4.0.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.1.3 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-4.0.0.rc1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.1.2 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.1.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.1.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.0.1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.0.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-3.0.0.rc1 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-2.8.0 lib/shoulda/matchers/active_record/uniqueness/namespace.rb
shoulda-matchers-2.8.0.rc2 lib/shoulda/matchers/active_record/uniqueness/namespace.rb