Sha256: 24bcef413260fd9de15c5c5829a5e9d0abf996e34bbe522d480f0c4eb7a0815e
Contents?: true
Size: 672 Bytes
Versions: 2
Compression:
Stored size: 672 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| begin role = role_class_name.create(:name => name.to_s) role.save rescue end end end end end module RoleClass module ClassMethods def find_roles(*role_names) all(:name => 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roles_data_mapper-0.3.1 | lib/roles_data_mapper/role.rb |
roles_data_mapper-0.3.0 | lib/roles_data_mapper/role.rb |