class Yml2erd::SchemaStructure
Attributes
structure_yml[RW]
table_names[RW]
Public Class Methods
new(yml)
click to toggle source
# File lib/yml2erd/schema_structure.rb, line 6 def initialize(yml) @structure_yml = yml @table_names = table_names end
Public Instance Methods
belongs(table_name)
click to toggle source
returns an array like below
- 'user_auths', 'companies'
# File lib/yml2erd/schema_structure.rb, line 25 def belongs(table_name) relation(table_name)['belongs_to'] end
columns(table_name)
click to toggle source
comment(table_name)
click to toggle source
index(table_name)
click to toggle source
relation(table_name)
click to toggle source
returns a hash like below { belongs_to: ['user_auths', 'companies'], has_many: ['posts'] }
# File lib/yml2erd/schema_structure.rb, line 19 def relation(table_name) relations = structure_yml[table_name]['relations'] end
relations()
click to toggle source
# File lib/yml2erd/schema_structure.rb, line 29 def relations table_names.map { |table_name| relation(table_name) } end
table(table_name)
click to toggle source
returns a hash like below
> {“columns”=>[{“name”=>“string”}, {“email”=>“string”}], “relations”=>{“belongs_to”=>[“user_auths”, “companies”], “has_many”=>}}¶ ↑
# File lib/yml2erd/schema_structure.rb, line 35 def table(table_name) structure_yml[table_name] end