lib/surrounded/context/role_map.rb in surrounded-0.9.1 vs lib/surrounded/context/role_map.rb in surrounded-0.9.2
- old
+ new
@@ -1,9 +1,29 @@
require 'triad'
require 'surrounded/context_errors'
module Surrounded
module Context
- class RoleMap < Triad
+ 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)
\ No newline at end of file