Class: CassandraCQL::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra-cql/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Schema

Returns a new instance of Schema.



21
22
23
24
25
26
27
# File 'lib/cassandra-cql/schema.rb', line 21

def initialize(schema)
  @schema = schema
  @column_families = {}
  @schema.cf_defs.each { |cf|
    @column_families[cf.name] = ColumnFamily.new(cf)
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/cassandra-cql/schema.rb', line 29

def method_missing(method, *args, &block)
  if @schema.respond_to?(method)
    @schema.send(method)
  else
    super(method, *args, &block)
  end
end

Instance Attribute Details

#column_familiesObject (readonly)

Returns the value of attribute column_families.



19
20
21
# File 'lib/cassandra-cql/schema.rb', line 19

def column_families
  @column_families
end

#schemaObject (readonly)

Returns the value of attribute schema.



19
20
21
# File 'lib/cassandra-cql/schema.rb', line 19

def schema
  @schema
end

Instance Method Details

#column_family_namesObject Also known as: tables



45
46
47
# File 'lib/cassandra-cql/schema.rb', line 45

def column_family_names
  @column_families.keys
end

#keyspaceObject



41
42
43
# File 'lib/cassandra-cql/schema.rb', line 41

def keyspace
  name
end

#to_sObject



37
38
39
# File 'lib/cassandra-cql/schema.rb', line 37

def to_s
  keyspace
end