Sha256: ccf5ac9ca3a90ad9ead244fd117ff6ed77c9b8b1f82c4b04e38cc9c0db282150
Contents?: true
Size: 626 Bytes
Versions: 6
Compression:
Stored size: 626 Bytes
Contents
module Roles::Base def valid_roles_are(*role_list) strategy_class.valid_roles = role_list.to_symbols if role_class_name role_list.each do |name| role_class_name.create(:name => name.to_s) end end end end class Role < ActiveRecord::Base class << self def find_roles(*role_names) where(:name.in => role_names.flatten) end def find_role role_name raise ArgumentError, "#find_role takes a single role name as argument, not: #{role_name.inspect}" if !role_name.kind_of_label? res = find_roles(role_name) res ? res.first : res end end end
Version data entries
6 entries across 6 versions & 1 rubygems