Class: DbAgile::Core::Schema::Part

Inherits:
SchemaObject show all
Defined in:
lib/dbagile/core/schema/part.rb

Instance Attribute Summary collapse

Attributes inherited from SchemaObject

#parent, #status

Instance Method Summary collapse

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?, #schema

Constructor Details

#initialize(name, definition) ⇒ Part

Creates a part instance



13
14
15
16
# File 'lib/dbagile/core/schema/part.rb', line 13

def initialize(name, definition)
  @name = name
  @definition = definition
end

Instance Attribute Details

#definitionObject (readonly)

Object definition



10
11
12
# File 'lib/dbagile/core/schema/part.rb', line 10

def definition
  @definition
end

#nameObject (readonly)

Object name



7
8
9
# File 'lib/dbagile/core/schema/part.rb', line 7

def name
  @name
end

Instance Method Details

#_sanity_check(schema) ⇒ Object

Makes a sanity check on the part



19
20
21
22
# File 'lib/dbagile/core/schema/part.rb', line 19

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

#_semantics_check(clazz, buffer) ⇒ Object

Checks this composite’s semantics and collect errors



25
26
# File 'lib/dbagile/core/schema/part.rb', line 25

def _semantics_check(clazz, buffer)
end

#dependencies(include_parent = false) ⇒ Object

Returns an array with part dependencies



33
34
35
# File 'lib/dbagile/core/schema/part.rb', line 33

def dependencies(include_parent = false)
  include_parent ? [ parent ] : []
end

#dupObject

Duplicates this part



53
54
55
# File 'lib/dbagile/core/schema/part.rb', line 53

def dup
  self.class.new(name, definition.dup)
end

#look_same_as?(other) ⇒ Boolean

Compares with another part

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/dbagile/core/schema/part.rb', line 47

def look_same_as?(other)
  return nil unless other.kind_of?(self.class)
  (name == other.name) and (definition == other.definition)
end

#to_sObject

Returns a string representation



58
59
60
# File 'lib/dbagile/core/schema/part.rb', line 58

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

#visit(&block) ⇒ Object



38
39
40
# File 'lib/dbagile/core/schema/part.rb', line 38

def visit(&block)
  block.call(self, parent)
end