Class: TableSaw::Associations
- Inherits:
-
Object
- Object
- TableSaw::Associations
- Defined in:
- lib/table_saw/associations.rb
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
Instance Method Summary collapse
- #belongs_to ⇒ Object
- #has_many ⇒ Object
-
#initialize(manifest) ⇒ Associations
constructor
A new instance of Associations.
Constructor Details
#initialize(manifest) ⇒ Associations
Returns a new instance of Associations.
7 8 9 |
# File 'lib/table_saw/associations.rb', line 7 def initialize(manifest) @manifest = manifest end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
5 6 7 |
# File 'lib/table_saw/associations.rb', line 5 def manifest @manifest end |
Instance Method Details
#belongs_to ⇒ Object
11 12 13 14 15 |
# File 'lib/table_saw/associations.rb', line 11 def belongs_to @belongs_to ||= foreign_keys.each_with_object(Hash.new { |h, k| h[k] = Set.new }) do |fk, memo| memo[fk.from_table].add(fk) end end |
#has_many ⇒ Object
17 18 19 20 21 |
# File 'lib/table_saw/associations.rb', line 17 def has_many @has_many ||= foreign_keys.each_with_object(Hash.new { |h, k| h[k] = Set.new }) do |fk, memo| memo[fk.to_table].add(fk) end end |