lib/direction.rb in direction-0.0.4 vs lib/direction.rb in direction-0.0.5
- old
+ new
@@ -16,35 +16,35 @@
# relationship between objects.
module Direction
# Forward messages and return self, protecting the encapsulation of the object
def command(options)
- Direction.define_methods(self, options) do |message, accessor|
+ Direction.define_methods(self, options) do |command, accessor|
%{
- def #{message}(*args, &block)
- #{accessor}.__send__(:#{message}, *args, &block)
+ def #{command}(*args, &block)
+ #{accessor}.__send__(:#{command}, *args, &block)
self
end
}
end
end
# Forward messages and return the result of the forwarded message
def query(options)
- Direction.define_methods(self, options) do |message, accessor|
+ Direction.define_methods(self, options) do |query, accessor|
%{
- def #{message}(*args, &block)
- #{accessor}.__send__(:#{message}, *args, &block)
+ def #{query}(*args, &block)
+ #{accessor}.__send__(:#{query}, *args, &block)
end
}
end
end
def self.define_methods(mod, options)
method_defs = []
options.each_pair do |method_names, accessor|
Array(method_names).map do |message|
- method_defs.unshift yield(message, accessor)
+ method_defs.push yield(message, accessor)
end
end
mod.class_eval method_defs.join("\n"), __FILE__, __LINE__
end
end