Class: DbAgile::Core::Schema::Logical::Constraint
- Inherits:
-
Part
- Object
- SchemaObject
- Part
- DbAgile::Core::Schema::Logical::Constraint
- Defined in:
- lib/dbagile/core/schema/logical/constraint.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Part
Attributes inherited from SchemaObject
Class Method Summary collapse
-
.factor(name, definition) ⇒ Object
Builds a constraint.
Instance Method Summary collapse
-
#candidate_key? ⇒ Boolean
Returns true if this constraint is a candidate key (including a primary key).
- #dependencies(include_parent = false) ⇒ Object
-
#foreign_key? ⇒ Boolean
Returns true if this constraint is a foreign key.
-
#primary_key? ⇒ Boolean
Returns true if this constraint is a primary key, false otherwise.
Methods inherited from Part
#_sanity_check, #_semantics_check, #dup, #initialize, #look_same_as?, #to_s, #visit
Methods inherited from SchemaObject
#ancestors, #attribute?, #builder_args, #builder_handler, #composite?, #constraint?, #index?, #logical?, #outside_dependencies, #outside_dependents, #part?, #physical?, #relation_variable, #relvar?, #relview?, #schema
Constructor Details
This class inherits a constructor from DbAgile::Core::Schema::Part
Class Method Details
.factor(name, definition) ⇒ Object
Builds a constraint
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dbagile/core/schema/logical/constraint.rb', line 12 def self.factor(name, definition) case kind = definition[:type] when :primary_key, :candidate_key, :key Schema::Logical::CandidateKey.new(name, definition) when :foreign_key Schema::Logical::ForeignKey.new(name, definition) else raise ArgumentError, "Unexpected constraint kind #{kind}" end end |
Instance Method Details
#candidate_key? ⇒ Boolean
Returns true if this constraint is a candidate key (including a primary key)
29 30 31 |
# File 'lib/dbagile/core/schema/logical/constraint.rb', line 29 def candidate_key? self.kind_of?(Logical::CandidateKey) end |
#dependencies(include_parent = false) ⇒ Object
48 49 50 |
# File 'lib/dbagile/core/schema/logical/constraint.rb', line 48 def dependencies(include_parent = false) include_parent ? [ parent ] : false end |
#foreign_key? ⇒ Boolean
Returns true if this constraint is a foreign key
39 40 41 |
# File 'lib/dbagile/core/schema/logical/constraint.rb', line 39 def foreign_key? self.kind_of?(Logical::ForeignKey) end |
#primary_key? ⇒ Boolean
Returns true if this constraint is a primary key, false otherwise
34 35 36 |
# File 'lib/dbagile/core/schema/logical/constraint.rb', line 34 def primary_key? candidate_key? and primary? end |