Class: ActiveRecord::ConnectionAdapters::SimpleDbTableDifinition
- Inherits:
-
TableDefinition
- Object
- TableDefinition
- ActiveRecord::ConnectionAdapters::SimpleDbTableDifinition
- Defined in:
- lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb
Instance Attribute Summary collapse
-
#collection_column_name ⇒ Object
readonly
Returns the value of attribute collection_column_name.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #column(name, type, options = {}) ⇒ Object
- #columns_with_defaults ⇒ Object
-
#initialize(collection_column_name) ⇒ SimpleDbTableDifinition
constructor
A new instance of SimpleDbTableDifinition.
-
#json(*args) ⇒ Object
for json type.
- #xml_column_fallback(*args) ⇒ Object
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_name ⇒ Object (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
20 21 22 23 24 |
# File 'lib/active_record/connection_adapters/simpledb_adapter/table_definition.rb', line 20 def column(name, type, = {}) 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, [:limit], [:precision], [:to], [:default]) self end |
#columns_with_defaults ⇒ Object
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) = args. column_names = args column_names.each { |name| column(name, 'json', ) } end |
#xml_column_fallback(*args) ⇒ Object
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 |