lib/surrounded/context/role_builders.rb in surrounded-0.8.4 vs lib/surrounded/context/role_builders.rb in surrounded-0.9.0

- old
+ new

@@ -1,19 +1,5 @@ -# Some features are only available in versions of Ruby -# where this method is true -unless defined?(module_method_rebinding?) - def module_method_rebinding? - return @__module_method_rebinding__ if defined?(@__module_method_rebinding__) - sample_method = Enumerable.instance_method(:to_a) - @__module_method_rebinding__ = begin - !!sample_method.bind(Object.new) - rescue TypeError - false - end - end -end - module Surrounded module Context module RoleBuilders # Define behaviors for your role players @@ -41,22 +27,20 @@ klass.send(:include, Surrounded) end alias_method :wrapper, :wrap - if module_method_rebinding? - # Create an object which will bind methods to the role player - def interface(name, &block) - class_basename = name.to_s.gsub(/(?:^|_)([a-z])/){ $1.upcase } - interface_name = class_basename + 'Interface' + # Create an object which will bind methods to the role player + def interface(name, &block) + class_basename = name.to_s.gsub(/(?:^|_)([a-z])/){ $1.upcase } + interface_name = class_basename + 'Interface' - behavior = private_const_set(interface_name, Module.new(&block)) + behavior = private_const_set(interface_name, Module.new(&block)) - require 'surrounded/context/negotiator' - undef_method(name) - define_method(name) do - instance_variable_set("@#{name}", Negotiator.new(role_map.assigned_player(name), behavior)) - end + require 'surrounded/context/negotiator' + undef_method(name) + define_method(name) do + instance_variable_set("@#{name}", Negotiator.new(role_map.assigned_player(name), behavior)) end end end end \ No newline at end of file