Class: Accessly::QueryBuilder
- Inherits:
-
Object
- Object
- Accessly::QueryBuilder
- Defined in:
- lib/accessly/query_builder.rb
Class Method Summary collapse
-
.with_actors(query, actors) ⇒ ActiveRecord::Relation
Builds a query with a series of actors ‘OR’ together.
Class Method Details
.with_actors(query, actors) ⇒ ActiveRecord::Relation
Builds a query with a series of actors ‘OR’ together
Use like this: ‘Accessly::QueryBuilder.with_actors(PermittedActionOnObject, => 1, Group => [2,3])`
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/accessly/query_builder.rb', line 12 def self.with_actors(query, actors) result_query = nil actors.each do |key, value| result_query = if result_query.nil? query.where(actor_type: String(key), actor_id: value) else result_query.or(query.where(actor_type: String(key), actor_id: value)) end end result_query end |