Class: Cassandra::Trigger

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/trigger.rb

Overview

Represents a trigger on a cassandra table

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameString (readonly)

Returns name of the trigger.

Returns:

  • (String)

    name of the trigger.



25
26
27
# File 'lib/cassandra/trigger.rb', line 25

def name
  @name
end

#optionsHash (readonly)

Returns options of the trigger.

Returns:

  • (Hash)

    options of the trigger.



27
28
29
# File 'lib/cassandra/trigger.rb', line 27

def options
  @options
end

#tableCassandra::Table (readonly)

Returns table that the trigger applies to.

Returns:



23
24
25
# File 'lib/cassandra/trigger.rb', line 23

def table
  @table
end

Instance Method Details

#custom_class_nameString

Returns name of the trigger class.

Returns:

  • (String)

    name of the trigger class



39
40
41
# File 'lib/cassandra/trigger.rb', line 39

def custom_class_name
  @options['class']
end

#to_cqlString

Returns a cql representation of this trigger.

Returns:

  • (String)

    a cql representation of this trigger



44
45
46
47
48
49
50
# File 'lib/cassandra/trigger.rb', line 44

def to_cql
  keyspace_name = Util.escape_name(@table.keyspace.name)
  table_name = Util.escape_name(@table.name)
  trigger_name = Util.escape_name(@name)

  "CREATE TRIGGER #{trigger_name} ON #{keyspace_name}.#{table_name} USING '#{@options['class']}';"
end