Class: Arc::DataStores::ObjectDefinitions::MysqlTable
- Inherits:
-
Table
- Object
- Table
- Arc::DataStores::ObjectDefinitions::MysqlTable
show all
- Defined in:
- lib/arc/data_stores/mysql/object_definitions.rb
Instance Attribute Summary
Attributes inherited from Table
#name
Instance Method Summary
collapse
Methods inherited from Table
#initialize
Instance Method Details
#fetch_item(name) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/arc/data_stores/mysql/object_definitions.rb', line 40
def fetch_item name
c = raw_column_data.find{|c| c[:Field] == name.to_s}
throw "Column '#{name}' does not exist" unless keys.include? name.to_sym
MysqlColumn.new @data_store,{
name: c[:Field],
allows_null: c[:Null] == "YES",
default: c[:Default],
primary_key: c[:Key] == "PRI",
type: c[:Type]
}
end
|
#fetch_keys ⇒ Object
37
38
39
|
# File 'lib/arc/data_stores/mysql/object_definitions.rb', line 37
def fetch_keys
raw_column_data.map {|c| c[:Field].to_sym }
end
|
#raw_column_data ⇒ Object
32
33
34
35
36
|
# File 'lib/arc/data_stores/mysql/object_definitions.rb', line 32
def raw_column_data
@data_store.read("show fields from #{self.name}").each do |r|
r
end
end
|