Class: TableSaw::DependencyGraph::BuildHasManyQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/dependency_graph/build_has_many_query.rb

Constant Summary collapse

QUERY =
<<~SQL.squish
  select %{primary_key} from %{table} where %{clause} and %{polymorphic}
SQL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest, directive, foreign_key) ⇒ BuildHasManyQuery

Returns a new instance of BuildHasManyQuery.



12
13
14
15
16
# File 'lib/table_saw/dependency_graph/build_has_many_query.rb', line 12

def initialize(manifest, directive, foreign_key)
  @manifest = manifest
  @directive = directive
  @foreign_key = foreign_key
end

Instance Attribute Details

#directiveObject (readonly)

Returns the value of attribute directive.



10
11
12
# File 'lib/table_saw/dependency_graph/build_has_many_query.rb', line 10

def directive
  @directive
end

#foreign_keyObject (readonly)

Returns the value of attribute foreign_key.



10
11
12
# File 'lib/table_saw/dependency_graph/build_has_many_query.rb', line 10

def foreign_key
  @foreign_key
end

#manifestObject (readonly)

Returns the value of attribute manifest.



10
11
12
# File 'lib/table_saw/dependency_graph/build_has_many_query.rb', line 10

def manifest
  @manifest
end

Instance Method Details

#callObject



18
19
20
21
22
# File 'lib/table_saw/dependency_graph/build_has_many_query.rb', line 18

def call
  build_base_query
    .then { |query| append_scope(query) }
    .then { |query| append_limit(query) }
end