Class: DbSchema::Definitions::ForeignKey
- Inherits:
-
Object
- Object
- DbSchema::Definitions::ForeignKey
- Defined in:
- lib/db_schema/definitions.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#on_delete ⇒ Object
readonly
Returns the value of attribute on_delete.
-
#on_update ⇒ Object
readonly
Returns the value of attribute on_update.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #deferrable? ⇒ Boolean
-
#initialize(name:, fields:, table:, keys: [], on_update: :no_action, on_delete: :no_action, deferrable: false) ⇒ ForeignKey
constructor
A new instance of ForeignKey.
- #options ⇒ Object
- #references_primary_key? ⇒ Boolean
Constructor Details
#initialize(name:, fields:, table:, keys: [], on_update: :no_action, on_delete: :no_action, deferrable: false) ⇒ ForeignKey
Returns a new instance of ForeignKey.
93 94 95 96 97 98 99 100 101 |
# File 'lib/db_schema/definitions.rb', line 93 def initialize(name:, fields:, table:, keys: [], on_update: :no_action, on_delete: :no_action, deferrable: false) @name = name @fields = fields @table = table @keys = keys @on_update = on_update @on_delete = on_delete @deferrable = deferrable end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def fields @fields end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def keys @keys end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def name @name end |
#on_delete ⇒ Object (readonly)
Returns the value of attribute on_delete.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def on_delete @on_delete end |
#on_update ⇒ Object (readonly)
Returns the value of attribute on_update.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def on_update @on_update end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
91 92 93 |
# File 'lib/db_schema/definitions.rb', line 91 def table @table end |
Instance Method Details
#deferrable? ⇒ Boolean
107 108 109 |
# File 'lib/db_schema/definitions.rb', line 107 def deferrable? @deferrable end |
#options ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/db_schema/definitions.rb', line 111 def { deferrable: deferrable?, name: name, on_delete: on_delete, on_update: on_update }.tap do || [:key] = keys unless references_primary_key? end end |
#references_primary_key? ⇒ Boolean
103 104 105 |
# File 'lib/db_schema/definitions.rb', line 103 def references_primary_key? keys.empty? end |