lib/surrounded/context.rb in surrounded-1.0.0 vs lib/surrounded/context.rb in surrounded-1.1.0

- old
+ new

@@ -1,8 +1,9 @@ require 'set' require 'surrounded/exceptions' require 'surrounded/context/role_map' +require 'surrounded/context/seclusion' require 'surrounded/context/role_builders' require 'surrounded/context/initializing' require 'surrounded/context/forwarding' require 'surrounded/context/trigger_controls' require 'surrounded/access_control' @@ -18,11 +19,11 @@ # which encapsulate the interaction and behavior of objects inside. module Surrounded module Context def self.extended(base) base.class_eval { - extend RoleBuilders, Initializing, Forwarding, NameCollisionDetector + extend Seclusion, RoleBuilders, Initializing, Forwarding, NameCollisionDetector @triggers = Set.new include InstanceMethods trigger_mod = Module.new @@ -67,25 +68,10 @@ def role_const_defined?(name) const_defined?(name, false) end - # Set a named constant and make it private - def private_const_set(name, const) - unless role_const_defined?(name) - const = const_set(name, const) - private_constant name.to_sym - end - const - end - - # Create attr_reader for the named methods and make them private - def private_attr_reader(*method_names) - attr_reader(*method_names) - private(*method_names) - end - # Conditional const_get for a named role behavior def role_const(name) if role_const_defined?(name) const_get(name) end @@ -117,13 +103,14 @@ # Return a Set of all defined triggers def triggers self.class.triggers end + # Reuse the same context object but pass new values def rebind(**options_hash) clear_instance_variables begin - initialize(options_hash) + initialize(**options_hash) rescue ArgumentError initialize(*options_hash.values) end self end