Class: CassandraMapper::Index::Observer

Inherits:
Observer show all
Defined in:
lib/cassandra_mapper/indexing.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Observer

#initialize, observe, observed_class, #observed_class_inherited, observed_classes, #observed_classes, #update

Constructor Details

This class inherits a constructor from CassandraMapper::Support::Observer

Class Attribute Details

.indexObject

Returns the value of attribute index.



425
426
427
# File 'lib/cassandra_mapper/indexing.rb', line 425

def index
  @index
end

Class Method Details

.activate!(index_object) ⇒ Object



427
428
429
430
431
# File 'lib/cassandra_mapper/indexing.rb', line 427

def activate!(index_object)
  observe index_object.indexed_class
  self.index = index_object
  instance
end

Instance Method Details

#after_create(instance) ⇒ Object



445
446
447
448
# File 'lib/cassandra_mapper/indexing.rb', line 445

def after_create(instance)
  index.create(instance)
  instance
end

#after_destroy(instance) ⇒ Object



455
456
457
458
# File 'lib/cassandra_mapper/indexing.rb', line 455

def after_destroy(instance)
  index.remove(instance)
  instance
end

#after_load(instance) ⇒ Object



438
439
440
441
442
443
# File 'lib/cassandra_mapper/indexing.rb', line 438

def after_load(instance)
  state = index.state_for(instance)
  state.source_value     = index.source_for(instance)
  state.identifier_value = index.indexed_identifier_for(instance)
  instance
end

#after_update(instance) ⇒ Object



450
451
452
453
# File 'lib/cassandra_mapper/indexing.rb', line 450

def after_update(instance)
  index.update(instance)
  instance
end

#indexObject



434
435
436
# File 'lib/cassandra_mapper/indexing.rb', line 434

def index
  self.class.index
end