Class: FlattenDB::MySQL
Constant Summary collapse
- JOIN_KEY =
:@key
Constants inherited from Base
Base::BUILDER_OPTIONS, Base::ELEMENT_CHARS, Base::ELEMENT_START
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
#config, #input, #output, #root
Instance Method Summary collapse
- #flatten!(options = {}) ⇒ Object
-
#initialize(options) ⇒ MySQL
constructor
A new instance of MySQL.
- #parse(tables = {}) ⇒ Object
- #to_xml(output = output, builder_options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options) ⇒ MySQL
Returns a new instance of MySQL.
43 44 45 46 47 48 |
# File 'lib/flattendb/types/mysql.rb', line 43 def initialize() super @type = [:type] || :xml @name, @tables = parse end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
41 42 43 |
# File 'lib/flattendb/types/mysql.rb', line 41 def builder @builder end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/flattendb/types/mysql.rb', line 41 def name @name end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
41 42 43 |
# File 'lib/flattendb/types/mysql.rb', line 41 def tables @tables end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
41 42 43 |
# File 'lib/flattendb/types/mysql.rb', line 41 def type @type end |
Instance Method Details
#flatten!(options = {}) ⇒ Object
54 55 56 57 |
# File 'lib/flattendb/types/mysql.rb', line 54 def flatten!( = {}) flatten_tables!(tables, root, config) self end |
#parse(tables = {}) ⇒ Object
50 51 52 |
# File 'lib/flattendb/types/mysql.rb', line 50 def parse(tables = {}) [send("parse_#{type}", tables) || 'root', tables] end |
#to_xml(output = output, builder_options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/flattendb/types/mysql.rb', line 59 def to_xml(output = output, = {}) initialize_builder(:xml, output, ) builder.instruct! if tables.size > 1 builder.tag!(name) { tables.sort.each { |table, rows| table_to_xml(table, rows, builder) } } else table_to_xml(name, tables.values.first, builder) end self end |