Class: DbAgile::Core::Schema::DatabaseSchema
- Inherits:
-
Composite
- Object
- SchemaObject
- Composite
- DbAgile::Core::Schema::DatabaseSchema
- Includes:
- Enumerable
- Defined in:
- lib/dbagile/core/schema/database_schema.rb
Instance Attribute Summary collapse
-
#schema_identifier ⇒ Object
Identifier of this schema.
Attributes inherited from SchemaObject
Instance Method Summary collapse
- #_default_parts ⇒ Object
- #_install_eigenclass_methods? ⇒ Boolean
-
#_strip! ⇒ Object
Strips this schema.
-
#check!(raise_on_error = true) ⇒ Object
Applies schema checking and raises a SchemaSemanticsError if something is wrong.
-
#dependencies(include_parent = false) ⇒ Object
Returns an array with part dependencies.
- #dup ⇒ Object
-
#filter(options = {}, &filter_block) ⇒ Object
Applies schema filtering.
-
#initialize(schema_identifier = nil, parts = _default_parts) ⇒ DatabaseSchema
constructor
Creates a schema instance.
-
#looks_valid? ⇒ Boolean
Convenient method for
schema.check!(false).empty?
. -
#merge(other) ⇒ Object
(also: #+)
Applies schema merging.
-
#minus(other) ⇒ Object
(also: #-)
Applies schema minus.
-
#schema ⇒ Object
Overrided to return self.
-
#split(options = {}, &split_block) ⇒ Object
Applies schema splitting.
-
#to_yaml(opts = {}) ⇒ Object
(also: #inspect)
Dumps the schema to YAML.
-
#yaml_display(env, options = {}, colors = DbAgile::Core::Schema::STATUS_TO_COLOR, indent = 0) ⇒ Object
Returns a yaml string.
Methods inherited from Composite
#[], #[]=, #each_part, #empty?, #look_same_as?, #part_keys, #parts, #size, #to_s, #visit
Methods inherited from SchemaObject
#ancestors, #attribute?, #builder_args, #builder_handler, #candidate_key?, #composite?, #constraint?, #foreign_key?, #index?, #logical?, #outside_dependencies, #outside_dependents, #part?, #physical?, #primary_key?, #relation_variable, #relvar?, #relview?
Constructor Details
#initialize(schema_identifier = nil, parts = _default_parts) ⇒ DatabaseSchema
Creates a schema instance
12 13 14 15 16 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 12 def initialize(schema_identifier = nil, parts = _default_parts) @schema_identifier = schema_identifier super(parts) @insert_order = [:logical, :physical] end |
Instance Attribute Details
#schema_identifier ⇒ Object
Identifier of this schema
9 10 11 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 9 def schema_identifier @schema_identifier end |
Instance Method Details
#_default_parts ⇒ Object
29 30 31 32 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 29 def _default_parts {:logical => Schema::Logical.new, :physical => Schema::Physical.new} end |
#_install_eigenclass_methods? ⇒ Boolean
24 25 26 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 24 def _install_eigenclass_methods? true end |
#_strip! ⇒ Object
Strips this schema
35 36 37 38 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 35 def _strip! logical._strip! self end |
#check!(raise_on_error = true) ⇒ Object
Applies schema checking and raises a SchemaSemanticsError if something is wrong.
87 88 89 90 91 92 93 94 95 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 87 def check!(raise_on_error = true) errors = SchemaSemanticsError.new(self) _semantics_check(SchemaSemanticsError, errors) if raise_on_error and not(errors.empty?) raise errors else errors end end |
#dependencies(include_parent = false) ⇒ Object
Returns an array with part dependencies
45 46 47 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 45 def dependencies(include_parent = false) [] end |
#dup ⇒ Object
55 56 57 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 55 def dup DatabaseSchema.new(schema_identifier, _dup_parts) end |
#filter(options = {}, &filter_block) ⇒ Object
Applies schema filtering
115 116 117 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 115 def filter( = {}, &filter_block) Schema::filter(self, , &filter_block) end |
#looks_valid? ⇒ Boolean
Convenient method for schema.check!(false).empty?
98 99 100 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 98 def looks_valid? check!(false).empty? end |
#merge(other) ⇒ Object Also known as: +
Applies schema merging
109 110 111 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 109 def merge(other) Schema::merge(self, other) end |
#minus(other) ⇒ Object Also known as: -
Applies schema minus
103 104 105 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 103 def minus(other) Schema::minus(self, other) end |
#schema ⇒ Object
Overrided to return self.
50 51 52 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 50 def schema self end |
#split(options = {}, &split_block) ⇒ Object
Applies schema splitting
120 121 122 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 120 def split( = {}, &split_block) Schema::split(self, , &split_block) end |
#to_yaml(opts = {}) ⇒ Object Also known as: inspect
Dumps the schema to YAML
65 66 67 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 65 def to_yaml(opts = {}) YAML::dump_stream({'logical' => logical}, {'physical' => physical}) end |
#yaml_display(env, options = {}, colors = DbAgile::Core::Schema::STATUS_TO_COLOR, indent = 0) ⇒ Object
Returns a yaml string
72 73 74 75 76 77 78 79 80 |
# File 'lib/dbagile/core/schema/database_schema.rb', line 72 def yaml_display(env, = {}, colors = DbAgile::Core::Schema::STATUS_TO_COLOR, indent = 0) env.display("---\nlogical:") logical.yaml_display(env, , colors, indent + 1) env.display("\n---\nphysical:") physical.yaml_display(env, , colors, indent + 1) end |