Sha256: 6d1a747e51d110941b9be74e7d9ecb16c447d624f6736a22615d95f0769e5493
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
module Eaco module Adapters ## # PostgreSQL 9.4 and up backing store for ACLs. # # @see ACL # @see PostgresJSONb # module ActiveRecord autoload :PostgresJSONb, 'eaco/adapters/active_record/postgres_jsonb' autoload :Compatibility, 'eaco/adapters/active_record/compatibility' ## # Currently defined collection extraction strategies. # # @return Hash # def self.strategies {:pg_jsonb => PostgresJSONb} end ## # Checks whether the model's data structure fits the ACL persistance # requirements. # # @param base [Class] your application's model # # @return void # def self.included(base) Compatibility.new(base).check! return unless base.table_exists? 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 ## # @return [ACL] this Resource's ACL. # # @see ACL # def acl acl = read_attribute(:acl) self.class.acl.new(acl) end ## # Sets the Resource's ACL. # # @param acl [ACL] the new ACL to set. # # @return [ACL] # # @see ACL # def acl=(acl) write_attribute :acl, acl.to_hash end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eaco-1.1.2 | lib/eaco/adapters/active_record.rb |
eaco-1.0.0 | lib/eaco/adapters/active_record.rb |
eaco-0.8.2 | lib/eaco/adapters/active_record.rb |