Class: ActiveRecord::ConnectionAdapters::SimpleDbTableDifinition

Inherits:
TableDefinition
  • Object
show all
Defined in:
lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection_column_name) ⇒ SimpleDbTableDifinition

Returns a new instance of SimpleDbTableDifinition.



7
8
9
10
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 7

def initialize collection_column_name
  super nil
  @collection_column_name = collection_column_name
end

Instance Attribute Details

#collection_column_nameObject (readonly)

Returns the value of attribute collection_column_name.



5
6
7
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 5

def collection_column_name
  @collection_column_name
end

Instance Method Details

#[](name) ⇒ Object



16
17
18
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 16

def [](name)
  @columns.find {|column| column.db_column_name == name.to_s}
end

#column(name, type, options = {}) ⇒ Object

Raises:

  • (ConfigurationError)


20
21
22
23
24
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 20

def column(name, type, options = {})
  raise ConfigurationError, %Q(column '#{collection_column_name}' reserved, please change column name) if name.to_s == collection_column_name
  @columns << SimpleDBColumn.new(name.to_s, type.to_sym, options[:limit], options[:precision], options[:to], options[:default])
  self
end

#columns_with_defaultsObject



26
27
28
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 26

def columns_with_defaults
  @columns_with_defaults ||= @columns.select { |column| column.default.present? }
end

#json(*args) ⇒ Object

for json type



31
32
33
34
35
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 31

def json(*args)
  options = args.extract_options!                                       
  column_names = args                                                   
  column_names.each { |name| column(name, 'json', options) }  
end

#xml_column_fallback(*args) ⇒ Object

Raises:

  • (ConfigurationError)


12
13
14
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 12

def xml_column_fallback(*args)
  raise ConfigurationError, "Not supported"
end