lib/contextr/class_methods.rb in contextr-0.1.9 vs lib/contextr/class_methods.rb in contextr-1.0.0
- old
+ new
@@ -7,13 +7,13 @@
hash[key] = Hash.new
end
end
def stored_module_definitions
- @stored_module_definitions ||= Hash.new do |hash, key|
- hash[key] = Hash.new do |hash, key|
- hash[key] = Module.new
+ @stored_module_definitions ||= Hash.new do |layer_hash, layer|
+ layer_hash[layer] = Hash.new do |extended_modules_hash, x_module|
+ extended_modules_hash[x_module] = Module.new
end
end
end
def active_layers_as_classes
@@ -38,20 +38,28 @@
def call_methods_stack(stack, receiver, method_name, arguments, block)
if stack.size == 1
stack.pop.call(*arguments, &block)
else
- stack.pop.__send__(method_name, *arguments) do | action, *rest_args |
+ stack.pop.__send__(method_name, *arguments) do |action, *rest_args|
case action
when :receiver
receiver
when :block
+ block
+ when :block!
block.call(*rest_args)
+ when :block=
+ block = rest_args.first
+ when :block_given?
+ !block.nil?
when :next
+ rest_args.shift unless method_name == :method_missing
call_methods_stack(stack, receiver, method_name, rest_args, block)
else
- raise ArgumentError.new("Use only :receiver, :block or :next " +
- "as first argument.")
+ raise ArgumentError, "Use only :receiver, :block, :block_given?, " +
+ ":block!, :block=, or :next " +
+ "as first argument."
end
end
end
end