Module: Eaco::Adapters::ActiveRecord
- Defined in:
- lib/eaco/adapters/active_record.rb,
lib/eaco/adapters/active_record/compatibility.rb,
lib/eaco/adapters/active_record/postgres_jsonb.rb,
lib/eaco/adapters/active_record/compatibility/v32.rb,
lib/eaco/adapters/active_record/compatibility/v40.rb,
lib/eaco/adapters/active_record/compatibility/v41.rb,
lib/eaco/adapters/active_record/compatibility/v42.rb,
lib/eaco/adapters/active_record/compatibility/scoped.rb
Overview
PostgreSQL 9.4 and up backing store for ACLs.
Defined Under Namespace
Modules: PostgresJSONb Classes: Compatibility
Class Method Summary collapse
-
.included(base) ⇒ Object
Checks whether the model’s data structure fits the ACL persistance requirements.
-
.strategies ⇒ Object
Currently defined collection extraction strategies.
Instance Method Summary collapse
-
#acl ⇒ ACL
This Resource’s ACL.
-
#acl=(acl) ⇒ ACL
Sets the Resource’s ACL.
Class Method Details
.included(base) ⇒ Object
Checks whether the model’s data structure fits the ACL persistance requirements.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/eaco/adapters/active_record.rb', line 31 def self.included(base) Compatibility.new(base).check! column = base.columns_hash.fetch('acl', nil) unless column raise Malformed, "Please define a jsonb column named `acl` on #{base}." end unless column.type == :json || column.type == :jsonb raise Malformed, "The `acl` column on #{base} must be of the jsonb type." end end |
.strategies ⇒ Object
Currently defined collection extraction strategies.
19 20 21 |
# File 'lib/eaco/adapters/active_record.rb', line 19 def self.strategies {:pg_jsonb => PostgresJSONb} end |
Instance Method Details
#acl ⇒ ACL
Returns this Resource’s ACL.
50 51 52 53 |
# File 'lib/eaco/adapters/active_record.rb', line 50 def acl acl = read_attribute(:acl) self.class.acl.new(acl) end |
#acl=(acl) ⇒ ACL
Sets the Resource’s ACL.
64 65 66 |
# File 'lib/eaco/adapters/active_record.rb', line 64 def acl=(acl) write_attribute :acl, acl.to_hash end |