Class: CassandraCQL::ColumnFamily
- Inherits:
-
Object
- Object
- CassandraCQL::ColumnFamily
- Defined in:
- lib/cassandra-cql/schema.rb
Instance Attribute Summary collapse
-
#cf_def ⇒ Object
readonly
Returns the value of attribute cf_def.
Class Method Summary collapse
Instance Method Summary collapse
- #columns ⇒ Object
- #id ⇒ Object
-
#initialize(cf_def) ⇒ ColumnFamily
constructor
A new instance of ColumnFamily.
- #method_missing(method, *args, &block) ⇒ Object
- #name ⇒ Object
- #standard? ⇒ Boolean
- #super? ⇒ Boolean
- #type ⇒ Object
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_def ⇒ Object (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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cassandra-cql/schema.rb', line 78 def self.cast(value, type) return nil if value.nil? if type =~ /^(List|Set|Map)Type\((.+)\)$/ collection_type, value_type = $1, $2 case collection_type when 'List' CassandraCQL::Collections::List.cast(value) do |element| cast(element, value_type) end when 'Set' CassandraCQL::Collections::Set.cast(value) do |element| cast(element, value_type) end when 'Map' key_type, map_value_type = value_type.split(',') CassandraCQL::Collections::Map.cast(value) do |key, element| [cast(key, key_type), cast(element, map_value_type)] end end elsif CassandraCQL::Types.const_defined?(type) CassandraCQL::Types.const_get(type).cast(value) else CassandraCQL::Types::AbstractType.cast(value) end end |
Instance Method Details
#columns ⇒ Object
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 |
#id ⇒ Object
113 114 115 |
# File 'lib/cassandra-cql/schema.rb', line 113 def id @cf_def.id end |
#name ⇒ Object
105 106 107 |
# File 'lib/cassandra-cql/schema.rb', line 105 def name @cf_def.name end |
#standard? ⇒ Boolean
117 118 119 |
# File 'lib/cassandra-cql/schema.rb', line 117 def standard? type == 'Standard' end |
#super? ⇒ Boolean
121 122 123 |
# File 'lib/cassandra-cql/schema.rb', line 121 def super? type == 'Super' end |
#type ⇒ Object
109 110 111 |
# File 'lib/cassandra-cql/schema.rb', line 109 def type @cf_def.column_type end |