Sha256: 8d02b9c13b1123838381293fea21327e46363e03dad25543627cf0c52897d08f

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Contexts

    # Describes the Cassandra user-defined type
    #
    class Type < Base

      attribute :keyspace, required: true
      attribute :name, required: true

      # Returns the full name of the type
      #
      # @return [String]
      #
      def to_s
        [keyspace, name].join(".")
      end

      # Returns the field context
      #
      # @param [#to_s] name
      #
      # @return [QueryBuilder::CQL::Contexts::Field]
      #
      def field(name)
        Contexts::Field.new(type: self, name: name)
      end

      # Builds the 'CREATE TYPE' CQL statement
      #
      # @return [QueryBuilder::Statements::CreateType]
      #
      def create
        Statements::CreateType.new(context: self)
      end

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

    end # class Type

  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/type.rb
query_builder-0.0.3 lib/query_builder/cql/contexts/type.rb
query_builder-0.0.2 lib/query_builder/cql/contexts/type.rb
query_builder-0.0.1 lib/query_builder/cql/contexts/type.rb