Class: CassandraCQL::ColumnFamily

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cf_def) ⇒ ColumnFamily

Returns a new instance of ColumnFamily.



54
55
56
# File 'lib/cassandra-cql/schema.rb', line 54

def initialize(cf_def)
  @cf_def = cf_def
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



58
59
60
61
62
63
64
# File 'lib/cassandra-cql/schema.rb', line 58

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

Instance Attribute Details

#cf_defObject (readonly)

Returns the value of attribute cf_def.



52
53
54
# File 'lib/cassandra-cql/schema.rb', line 52

def cf_def
  @cf_def
end

Class Method Details

.cast(value, type) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/cassandra-cql/schema.rb', line 78

def self.cast(value, type)
  return nil if value.nil?

  if CassandraCQL::Types.const_defined?(type)
    CassandraCQL::Types.const_get(type).cast(value)
  else
    CassandraCQL::Types::AbstractType.cast(value)
  end
end

Instance Method Details

#columnsObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cassandra-cql/schema.rb', line 66

def columns
  return @columns if @columns

  @columns = Hash.new(default_validation_class)
  @cf_def..each do |col|
    @columns[col.name] = col.validation_class
  end
  @columns[key_alias] = key_validation_class

  @columns
end

#idObject



96
97
98
# File 'lib/cassandra-cql/schema.rb', line 96

def id
  @cf_def.id
end

#nameObject



88
89
90
# File 'lib/cassandra-cql/schema.rb', line 88

def name
  @cf_def.name
end

#standard?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/cassandra-cql/schema.rb', line 100

def standard?
  type == 'Standard'
end

#super?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/cassandra-cql/schema.rb', line 104

def super?
  type == 'Super'
end

#typeObject



92
93
94
# File 'lib/cassandra-cql/schema.rb', line 92

def type
  @cf_def.column_type
end