Class: SchemaRD::Table

Inherits:
Struct
  • Object
show all
Includes:
Utils::StructAssigner
Defined in:
lib/schemard/schema.rb

Instance Method Summary collapse

Methods included from Utils::StructAssigner

#assign

Constructor Details

#initialize(hash = nil) ⇒ Table

Returns a new instance of Table.



27
28
29
30
31
32
# File 'lib/schemard/schema.rb', line 27

def initialize(hash = nil)
  self.columns = []
  self.indexes = []
  self.position = { "left" => 0, "top" => 0 }
  self.assign(hash)
end

Instance Method Details

#default_position?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/schemard/schema.rb', line 48

def default_position?
  self.position["left"] == 0 && self.position["top"] == 0
end

#display_nameObject



45
46
47
# File 'lib/schemard/schema.rb', line 45

def display_name
  self.localized_name || self.name
end

#relation_to(table_name) ⇒ Object



42
43
44
# File 'lib/schemard/schema.rb', line 42

def relation_to(table_name)
  self.relations_as_parent.find{|r| r.child_table.name == table_name }
end

#relations_as_childObject



39
40
41
# File 'lib/schemard/schema.rb', line 39

def relations_as_child
  @schema.relations.select{|r| r.child_table == self }
end

#relations_as_parentObject



36
37
38
# File 'lib/schemard/schema.rb', line 36

def relations_as_parent
  @schema.relations.select{|r| r.parent_table == self }
end

#set_schema(schema) ⇒ Object



33
34
35
# File 'lib/schemard/schema.rb', line 33

def set_schema(schema)
  @schema = schema
end