Skip to content

Commit

Permalink
Introduce ApplicationQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
aviav committed Jul 28, 2017
1 parent c536f13 commit 592fc11
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
9 changes: 2 additions & 7 deletions app/models/pageflow/account_member_query.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Pageflow
class AccountMemberQuery
class Scope
class AccountMemberQuery < ApplicationQuery
class Scope < Scope
# Account whose members we scope
# @return {Pageflow::Account}
attr_reader :account
Expand Down Expand Up @@ -52,11 +52,6 @@ def memberships_for_account_with_at_least_role(role)
def membership_is_present
'pageflow_account_memberships.entity_id IS NOT NULL'
end

# @api private
def sanitize_sql(sql, interpolations)
ActiveRecord::Base.send(:sanitize_sql_array, [sql, interpolations])
end
end
end
end
12 changes: 12 additions & 0 deletions app/models/pageflow/application_query.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Pageflow
class ApplicationQuery
class Scope
protected

# @api protected
def sanitize_sql(sql, interpolations)
ActiveRecord::Base.send(:sanitize_sql_array, [sql, interpolations])
end
end
end
end
8 changes: 2 additions & 6 deletions app/models/pageflow/entry_role_query.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Pageflow
class EntryRoleQuery
class Scope
class EntryRoleQuery < ApplicationQuery
class Scope < Scope
attr_reader :user, :scope

def initialize(user, scope)
Expand Down Expand Up @@ -50,10 +50,6 @@ def either_membership_is_present
'pageflow_entry_memberships.entity_id IS NOT NULL OR ' \
'pageflow_entry_account_memberships.entity_id IS NOT NULL'
end

def sanitize_sql(sql, interpolations)
ActiveRecord::Base.send(:sanitize_sql_array, [sql, interpolations])
end
end

def initialize(user, entry)
Expand Down

0 comments on commit 592fc11

Please sign in to comment.