Class: TableSaw::DependencyGraph::Context
- Inherits:
-
Object
- Object
- TableSaw::DependencyGraph::Context
- Defined in:
- lib/table_saw/dependency_graph/context.rb
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
Instance Method Summary collapse
- #belongs_to ⇒ Object
-
#foreign_key_relationships ⇒ Object
rubocop:enable Naming/PredicateName.
-
#has_many ⇒ Object
rubocop:disable Naming/PredicateName.
- #has_many_mapping ⇒ Object
-
#initialize(manifest) ⇒ Context
constructor
A new instance of Context.
- #perform_query(sql) ⇒ Object
- #tables_with_no_ids ⇒ Object
Constructor Details
#initialize(manifest) ⇒ Context
Returns a new instance of Context.
8 9 10 |
# File 'lib/table_saw/dependency_graph/context.rb', line 8 def initialize(manifest) @manifest = manifest end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
6 7 8 |
# File 'lib/table_saw/dependency_graph/context.rb', line 6 def manifest @manifest end |
Instance Method Details
#belongs_to ⇒ Object
12 13 14 |
# File 'lib/table_saw/dependency_graph/context.rb', line 12 def belongs_to foreign_key_relationships.belongs_to end |
#foreign_key_relationships ⇒ Object
rubocop:enable Naming/PredicateName
27 28 29 |
# File 'lib/table_saw/dependency_graph/context.rb', line 27 def foreign_key_relationships @foreign_key_relationships ||= TableSaw::Queries::ForeignKeyRelationships.new end |
#has_many ⇒ Object
rubocop:disable Naming/PredicateName
17 18 19 |
# File 'lib/table_saw/dependency_graph/context.rb', line 17 def has_many foreign_key_relationships.has_many end |
#has_many_mapping ⇒ Object
21 22 23 |
# File 'lib/table_saw/dependency_graph/context.rb', line 21 def has_many_mapping @has_many_mapping ||= manifest.tables.transform_values(&:has_many) end |
#perform_query(sql) ⇒ Object
35 36 37 38 39 |
# File 'lib/table_saw/dependency_graph/context.rb', line 35 def perform_query(sql) TableSaw::Connection.with do |conn| conn.exec(sql) end end |
#tables_with_no_ids ⇒ Object
31 32 33 |
# File 'lib/table_saw/dependency_graph/context.rb', line 31 def tables_with_no_ids @tables_with_no_ids ||= TableSaw::Queries::NoIdTables.new.call end |