Class: Pgerd::ForeignKey
- Inherits:
-
Object
- Object
- Pgerd::ForeignKey
- Includes:
- Comparable
- Defined in:
- lib/pgerd/foreign_key.rb
Instance Attribute Summary collapse
-
#from_column ⇒ Object
readonly
Returns the value of attribute from_column.
-
#from_table ⇒ Object
readonly
Returns the value of attribute from_table.
-
#to_column ⇒ Object
readonly
Returns the value of attribute to_column.
-
#to_table ⇒ Object
readonly
Returns the value of attribute to_table.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #for_table?(table) ⇒ Boolean
-
#initialize(data) ⇒ ForeignKey
constructor
A new instance of ForeignKey.
- #to_a_for_sorting ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ ForeignKey
6 7 8 9 10 11 |
# File 'lib/pgerd/foreign_key.rb', line 6 def initialize(data) @from_table = data['from_table'] @from_column = data['from_column'] @to_table = data['to_table'] @to_column = data['to_column'] end |
Instance Attribute Details
#from_column ⇒ Object (readonly)
Returns the value of attribute from_column.
4 5 6 |
# File 'lib/pgerd/foreign_key.rb', line 4 def from_column @from_column end |
#from_table ⇒ Object (readonly)
Returns the value of attribute from_table.
4 5 6 |
# File 'lib/pgerd/foreign_key.rb', line 4 def from_table @from_table end |
#to_column ⇒ Object (readonly)
Returns the value of attribute to_column.
4 5 6 |
# File 'lib/pgerd/foreign_key.rb', line 4 def to_column @to_column end |
#to_table ⇒ Object (readonly)
Returns the value of attribute to_table.
4 5 6 |
# File 'lib/pgerd/foreign_key.rb', line 4 def to_table @to_table end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 |
# File 'lib/pgerd/foreign_key.rb', line 17 def <=>(other) to_a_for_sorting <=> other.to_a_for_sorting end |
#for_table?(table) ⇒ Boolean
25 26 27 |
# File 'lib/pgerd/foreign_key.rb', line 25 def for_table?(table) @from_table == table || @to_table == table end |
#to_a_for_sorting ⇒ Object
21 22 23 |
# File 'lib/pgerd/foreign_key.rb', line 21 def to_a_for_sorting [@from_table, @from_column, @to_table, @to_column] end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/pgerd/foreign_key.rb', line 13 def to_s "#{@from_table}.#{@from_column} --> #{@to_table}.#{@to_column}" end |