Module: Eaco::Adapters::ActiveRecord::PostgresJSONb
- Defined in:
- lib/eaco/adapters/active_record/postgres_jsonb.rb
Overview
Authorized collection extractor on PostgreSQL >= 9.4 and a jsonb column named acl.
TODO negative authorizations (using a separate column?)
Instance Method Summary collapse
-
#accessible_by(actor) ⇒ ActiveRecord::Relation
Uses the json key existance operator ?| to check whether one of the
Actor‘sDesignatorinstances exist as keys in theACLobjects.
Instance Method Details
#accessible_by(actor) ⇒ ActiveRecord::Relation
Uses the json key existance operator ?| to check whether one of the Actor‘s Designator instances exist as keys in the ACL objects.
25 26 27 28 29 30 31 |
# File 'lib/eaco/adapters/active_record/postgres_jsonb.rb', line 25 def accessible_by(actor) return scoped if actor.is_admin? designators = actor.designators.map {|d| quote_value(d, nil) } where("acl ?| array[#{designators.join(',')}]::varchar[]") end |