Skip to content

Instantly share code, notes, and snippets.

@tbuyle
Created November 29, 2019 15:46
Show Gist options
  • Save tbuyle/c6cf3dfdf7fb5c4da0a56452dcb67559 to your computer and use it in GitHub Desktop.
Save tbuyle/c6cf3dfdf7fb5c4da0a56452dcb67559 to your computer and use it in GitHub Desktop.
def self.multi_scope(scopes)
my_scopes = Array.new
scopes.each do |scope|
m_scopes << self.send(scope) if self.respond_to? scope
end
if my_scopes.length == 0
return slef.none
else
f = my_scopes.delete_at(0)
my_scopes.each do |s|
f = f.or(s)
end
return f
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment