Class: SchemaRD::Table
- Inherits:
-
Struct
- Object
- Struct
- SchemaRD::Table
- Includes:
- Utils::StructAssigner
- Defined in:
- lib/schemard/schema.rb
Instance Method Summary collapse
- #default_position? ⇒ Boolean
- #display_name ⇒ Object
-
#initialize(hash = nil) ⇒ Table
constructor
A new instance of Table.
- #relation_to(table_name) ⇒ Object
- #relations_as_child ⇒ Object
- #relations_as_parent ⇒ Object
- #set_schema(schema) ⇒ Object
Methods included from Utils::StructAssigner
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
48 49 50 |
# File 'lib/schemard/schema.rb', line 48 def default_position? self.position["left"] == 0 && self.position["top"] == 0 end |
#display_name ⇒ Object
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_child ⇒ Object
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_parent ⇒ Object
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 |