Sha256: bb40f7fcddac180651b4aee5eddfce231206f715d3f208c97bb4a18af4b3eddc

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Contexts

    # Describes the Cassandra table column
    #
    class Column < Base

      attribute :table, required: true
      attribute :name,  required: true

      # Builds the 'ALTER TABLE ... ADD' CQL statement
      #
      # @param [#to_s] type
      # @param [Hash] options
      # @option options [Boolean] :static
      #
      # @return [QueryBuilder::Statements::AddColumn]
      #
      def create(type, options = {})
        Statements::CreateColumn
          .new(context: self, type: type, static: options[:static])
      end

      # Builds the 'ALTER TABLE ... RENAME' CQL statement
      #
      # @param [#to_s] name
      #
      # @return [QueryBuilder::Statements::RenameColumn]
      #
      def rename(name)
        Statements::RenameColumn.new(context: self, name: name)
      end

      # Builds the 'ALTER TABLE ... ALTER' CQL statement
      #
      # @param [#to_s] type
      #
      # @return [QueryBuilder::Statements::AlterColumn]
      #
      def alter(type)
        Statements::AlterColumn.new(context: self, type: type)
      end

      # Builds the 'ALTER TABLE ... DROP' CQL statement
      #
      # @return [QueryBuilder::Statements::DropColumn]
      #
      def drop
        Statements::DropColumn.new(context: self)
      end

    end # class Column

  end # module Contexts

end # module QueryBuilder::CQL

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
query_builder-0.0.4 lib/query_builder/cql/contexts/column.rb
query_builder-0.0.3 lib/query_builder/cql/contexts/column.rb
query_builder-0.0.2 lib/query_builder/cql/contexts/column.rb
query_builder-0.0.1 lib/query_builder/cql/contexts/column.rb