Class: Mkxms::Mssql::ForeignKeyHandler

Inherits:
Object
  • Object
show all
Includes:
PropertyHandler::ElementHandler
Defined in:
lib/mkxms/mssql/foreign_key_handler.rb

Instance Method Summary collapse

Methods included from PropertyHandler::ElementHandler

#handle_property_element

Constructor Details

#initialize(constraints, node) ⇒ ForeignKeyHandler

Returns a new instance of ForeignKeyHandler.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mkxms/mssql/foreign_key_handler.rb', line 60

def initialize(constraints, node)
  a = node.attributes
  
  @relation = ForeignKey.new(
    a['schema'], a['table'], a['name'], 
    on_delete: a['on-delete'], 
    on_update: a['on-update'], 
    enabled: !a['disabled']
  ).tap do |k|
    constraints << k
  end
end

Instance Method Details



79
80
81
82
83
# File 'lib/mkxms/mssql/foreign_key_handler.rb', line 79

def handle_link_element(parse)
  a = parse.node.attributes
  
  @relation.links << [a['from'], a['to']]
end

#handle_referent_element(parse) ⇒ Object



73
74
75
76
77
# File 'lib/mkxms/mssql/foreign_key_handler.rb', line 73

def handle_referent_element(parse)
  a = parse.node.attributes
  
  @relation.references = [a['schema'], a['name']]
end