Sha256: 06cd180ccb40207318b58425e0ed5573fb707cd630ce49c355e9896595b15730
Contents?: true
Size: 625 Bytes
Versions: 4
Compression:
Stored size: 625 Bytes
Contents
# frozen_string_literal: true require 'proxes/models/base' module ProxES class Permission < Base many_to_one :role many_to_one :user dataset_module do def for_user(a_user, action) where(verb: action).where { Sequel.|({ role: a_user.roles }, { user_id: a_user.id }) } end end def validate validates_presence [:verb, :pattern] validates_presence :role_id unless user_id validates_presence :user_id unless role_id validates_includes self.class.verbs, :verb end def self.verbs %w[GET POST PUT DELETE HEAD OPTIONS TRACE INDEX] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
proxes-0.4.4 | lib/proxes/models/permission.rb |
proxes-0.4.3 | lib/proxes/models/permission.rb |
proxes-0.4.2 | lib/proxes/models/permission.rb |
proxes-0.4.1 | lib/proxes/models/permission.rb |