Sha256: b955693f3700eb9cb6db4088341a871e1dfa5723ca9e04e98da6c5e817826c37
Contents?: true
Size: 942 Bytes
Versions: 2
Compression:
Stored size: 942 Bytes
Contents
require 'triad' require 'forwardable' module Surrounded module Context class RoleMap extend Forwardable class << self def from_base(klass=::Triad) role_mapper = Class.new(self) Surrounded::Exceptions.define(role_mapper, exceptions: :ItemNotPresent, namespace: klass) role_mapper.container_class=(klass) role_mapper.def_delegators :container, :update, :each, :values, :keys role_mapper end def container_class=(klass) @container_class = klass end end def container @container ||= self.class.instance_variable_get(:@container_class).new end def role?(role) keys.include?(role) end def role_player?(object) !values(object).empty? rescue ::StandardError false end def assigned_player(role) values(role).first end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
surrounded-1.0.0 | lib/surrounded/context/role_map.rb |
surrounded-0.9.11 | lib/surrounded/context/role_map.rb |