Class: CassandraMapper::Persistence::ClassMethods::SuperMutator

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra_mapper/persistence.rb

Instance Method Summary collapse

Instance Method Details

#from_simple(structure, timestamp) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/cassandra_mapper/persistence.rb', line 261

def from_simple(structure, timestamp)
  structure.inject([]) do |list, pair|
    supercol_key, val = pair
    if val and ! val.empty?
      list << CassandraThrift::Mutation.new(
        :column_or_supercolumn => CassandraThrift::ColumnOrSuperColumn.new(
          :super_column => CassandraThrift::SuperColumn.new(
            :name    => supercol_key,
            :columns => val.collect {|column, value|
              CassandraThrift::Column.new(
                :name      => column,
                :value     => value,
                :timestamp => timestamp
              )
            }
          )
        )
      )
    end
    list
  end
end