Class: DbAgile::Core::Schema::Logical::Relvar

Inherits:
Composite show all
Defined in:
lib/dbagile/core/schema/logical/relvar.rb

Instance Attribute Summary collapse

Attributes inherited from SchemaObject

#parent, #status

Instance Method Summary collapse

Methods inherited from Composite

#[], #[]=, #dependencies, #each_part, #empty?, #part_keys, #parts, #size, #to_yaml, #visit, #yaml_display

Methods inherited from SchemaObject

#ancestors, #attribute?, #builder_handler, #candidate_key?, #composite?, #constraint?, #foreign_key?, #index?, #logical?, #outside_dependencies, #outside_dependents, #part?, #physical?, #primary_key?, #relation_variable, #relvar?, #relview?, #schema

Constructor Details

#initialize(name, parts = _default_parts) ⇒ Relvar

Creates a relation variable instance



11
12
13
14
15
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 11

def initialize(name, parts = _default_parts)
  @name = name.to_s.to_sym
  super(parts)
  @insert_order = [ :heading, :constraints ] & parts.keys
end

Instance Attribute Details

#nameObject (readonly)

Relvar name



8
9
10
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 8

def name
  @name
end

Instance Method Details

#_install_eigenclass_methods?Boolean

Returns:

  • (Boolean)

See Also:

  • Composite#_install_eigenclass_methods?


22
23
24
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 22

def _install_eigenclass_methods?
  true
end

#_sanity_check(schema) ⇒ Object

Makes a sanity check on the part



33
34
35
36
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 33

def _sanity_check(schema)
  raise SchemaInternalError, "No name provided on #{self}" if name.nil?
  super(schema)
end

#_semantics_check(clazz, buffer) ⇒ Object

Checks this composite’s semantics and collects errors inside buffer



39
40
41
42
43
44
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 39

def _semantics_check(clazz, buffer)
  if constraints.primary_key.nil?
    buffer.add_error(self, clazz::MissingPrimaryKey)
  end
  super(clazz, buffer)
end

#builder_argsObject

Returns the arguments to pass to builder handler



51
52
53
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 51

def builder_args
  [ name ]
end

#dupObject

Duplicates this attribute



67
68
69
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 67

def dup
  Logical::Relvar.new(name, :heading => heading.dup, :constraints => constraints.dup)
end

#look_same_as?(other) ⇒ Boolean

Compares with another attribute

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 60

def look_same_as?(other)
  return nil unless other.kind_of?(Relvar)
  return false unless name == other.name
  super(other)
end

#to_sObject

Returns a string representation



72
73
74
# File 'lib/dbagile/core/schema/logical/relvar.rb', line 72

def to_s
  "#{DbAgile::RubyTools::unqualified_class_name(self.class)}: #{name}"
end