Sha256: 82f50beb4af93cf3914537ad1d5698f33fc20bc5cfe6b28b28f299d47403c73d
Contents?: true
Size: 975 Bytes
Versions: 8
Compression:
Stored size: 975 Bytes
Contents
require 'triad' require 'surrounded/context_errors' module Surrounded module Context class RoleMap class << self def from_base(klass=::Triad) role_mapper = Class.new(::Surrounded::Context::RoleMap) num = __LINE__; role_mapper.class_eval %{ def container @container ||= #{klass}.new end }, __FILE__, num %w{ update each values keys }.each do |meth| num = __LINE__; role_mapper.class_eval %{ def #{meth}(*args, &block) container.send(:#{meth}, *args, &block) end }, __FILE__, num end role_mapper end end def role?(role) keys.include?(role) end def role_player?(object) !values(object).empty? rescue ::Triad::ItemNotPresent false end def assigned_player(role) values(role).first end end end end
Version data entries
8 entries across 8 versions & 1 rubygems