Skip to content

Commit

Permalink
Allow user to pass any named scope
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronskiba committed Dec 12, 2023
1 parent a228250 commit 35c9bdb
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ def escape_entry(entry)
def extracted_db_entries
entries = []
@db_fields.keys.each do |table_name|
has_scope = @db_fields[table_name].key?(:scope)
scope = @db_fields[table_name][:scope] if has_scope
table = table_name.constantize
@db_fields[table_name].each do |column_name|
# Apply 'sync' scope, if it exists
db_strings = if table.respond_to?(:sync) then table.sync.distinct.pluck(column_name) else table.distinct.pluck(column_name) end
# Apply scope, if it exists
db_strings = if has_scope then table.method(scope).call.distinct.pluck(column_name) else table.distinct.pluck(column_name) end
entries += db_strings
end
end
Expand Down

0 comments on commit 35c9bdb

Please sign in to comment.