Module: ActiveColumn

Extended by:
Configuration
Included in:
Base
Defined in:
lib/active_column.rb,
lib/active_column/base.rb,
lib/active_column/errors.rb,
lib/active_column/helpers.rb,
lib/active_column/version.rb,
lib/active_column/migrator.rb,
lib/active_column/migration.rb,
lib/active_column/key_config.rb,
lib/active_column/configuration.rb,
lib/active_column/tasks/keyspace.rb,
lib/active_column/tasks/column_family.rb,
lib/active_column/generators/migration_generator.rb

Defined Under Namespace

Modules: ClassMethods, Configuration, Generators, Helpers, Tasks Classes: ActiveColumnError, Base, DuplicateMigrationNameError, DuplicateMigrationVersionError, IllegalMigrationNameError, IrreversibleMigration, KeyConfig, Migration, MigrationProxy, Migrator, UnknownMigrationVersionError

Constant Summary collapse

VERSION =
"0.2"

Instance Method Summary collapse

Methods included from Configuration

column_family_tasks, connect, connected?, connection, connection=, keyspace_tasks

Instance Method Details

#initialize(attrs = {}) ⇒ Object



50
51
52
53
54
# File 'lib/active_column/base.rb', line 50

def initialize(attrs = {})
  attrs.each do |attr, value|
    send("#{attr}=", value) if respond_to?("#{attr}=")
  end
end

#saveObject



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/active_column/base.rb', line 56

def save()
  value = { SimpleUUID::UUID.new => ActiveSupport::JSON.encode(self) }
  key_parts = self.class.keys.each_with_object( {} ) do |key_config, key_parts|
    key_parts[key_config.key] = self.send(key_config.func)
  end
  keys = self.class.generate_keys(key_parts)

  keys.each do |key|
    ActiveColumn.connection.insert(self.class.column_family, key, value)
  end

  self
end