Sha256: 428242f36d9eb5872c5c07e56fa77a2583eaa4b0d0db1eb0be7d2882636b2718

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Contexts

    # Describes the Cassandra table index
    #
    class Permission < Base

      attribute :name
      attribute :keyspace
      attribute :table

      # Returns the name of the context for permission
      #
      # @return [String]
      #
      def to_s
        return "TABLE #{table}" if table
        return "KEYSPACE #{keyspace}" if keyspace
        "ALL KEYSPACES"
      end

      # Builds the 'LIST PERMISSIONS' CQL statement
      #
      # @param [#to_s] name The name of either a user or role
      #
      # @return [QueryBuilder::Statements::ListPermissions]
      #
      def of(name)
        Statements::ListPermissions.new(context: self, name: name)
      end

      # Builds the 'GRANT' CQL statement
      #
      # @param [#to_s] name The name of either a user or role
      #
      # @return [QueryBuilder::Statements::Grant]
      #
      def grant_to(name)
        Statements::Grant.new(context: self, name: name)
      end

      # Builds the 'REVOKE' CQL statement
      #
      # @param [#to_s] name The name of either a user or role
      #
      # @return [QueryBuilder::Statements::Revoke]
      #
      def revoke_from(name)
        Statements::Revoke.new(context: self, name: name)
      end

    end # class Permission

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