Sha256: da6e5134a9a28064a64774400656dda4b125e0cd0f7cd7a439781e712d8b7cf1

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

module DataMapper
  module Adapters
    module Sql
      module Commands
    
        class TableExistsCommand
      
          def initialize(adapter, klass_or_name)
            @adapter, @klass_or_name = adapter, klass_or_name
          end
      
          def table_name
            @table_name || @table_name = case @klass_or_name
            when String then @adapter.quote_value(@klass_or_name)
            when Class then @adapter.quote_value(@adapter[@klass_or_name].name)
            else raise ArgumentError.new('klass_or_name must be a mapped-class or a table name')
            end
          end
          
          def to_sql
            "SHOW TABLES LIKE #{table_name}"
          end
          
          def call
            raise NotImplementedError.new
          end
      
        end
    
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper-0.1.1 lib/data_mapper/adapters/sql/commands/table_exists_command.rb