Sha256: 28a3fb0ac5cc9a086a5340169ab7c74a098923efc45c9a29979863394093c1f9
Contents?: true
Size: 575 Bytes
Versions: 12
Compression:
Stored size: 575 Bytes
Contents
module Roles::Base def valid_roles_are(*role_list) strategy_class.valid_roles = role_list.to_symbols end end class Role include Mongoid::Document field :name, :type => String validates_uniqueness_of :name class << self def find_roles(*role_names) where(:name.in => role_names.flatten).to_a 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
12 entries across 12 versions & 3 rubygems