Sha256: 3fc7521baf3cec3490e3faedac8cabbd5883428406fb44645d6befd85daa5aa0
Contents?: true
Size: 697 Bytes
Versions: 4
Compression:
Stored size: 697 Bytes
Contents
module Roles::Base def valid_roles_are(*role_list) strategy_class.valid_roles = role_list.to_symbols if role_class_name "Create Roles: #{role_list}" role_list.each do |name| role_class_name.create(:name => name.to_s) end else "Using Inline roles" 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
4 entries across 4 versions & 1 rubygems