lib/proxes/models/permission.rb in proxes-0.7.1 vs lib/proxes/models/permission.rb in proxes-0.8.0

- old
+ new

@@ -1,23 +1,25 @@ # frozen_string_literal: true -require 'proxes/models/base' +require 'ditty/models/base' +require 'ditty/models/user' +require 'ditty/models/role' module ProxES class Permission < Sequel::Model - include ::ProxES::Base + include ::Ditty::Base - many_to_one :role - many_to_one :user + many_to_one :role, class: ::Ditty::Role + many_to_one :user, class: ::Ditty::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 %i[verb pattern] validates_presence :role_id unless user_id validates_presence :user_id unless role_id validates_includes self.class.verbs, :verb end