Module: Direction
- Defined in:
- lib/direction.rb,
lib/direction/version.rb
Overview
relationship between objects.
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
Instance Method Summary collapse
-
#command(options) ⇒ Object
Forward messages and return self, protecting the encapsulation of the object.
-
#query(options) ⇒ Object
Forward messages and return the result of the forwarded message.
Class Method Details
.define_methods(mod, options) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/direction.rb', line 42 def self.define_methods(mod, ) method_defs = [] .each_pair do |method_names, accessor| Array(method_names).map do || method_defs.unshift yield(, accessor) end end mod.class_eval method_defs.join("\n"), __FILE__, __LINE__ end |
Instance Method Details
#command(options) ⇒ Object
Forward messages and return self, protecting the encapsulation of the object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/direction.rb', line 20 def command() Direction.define_methods(self, ) do |, accessor| %{ def #{}(*args, &block) #{accessor}.__send__(:#{}, *args, &block) self end } end end |
#query(options) ⇒ Object
Forward messages and return the result of the forwarded message
32 33 34 35 36 37 38 39 40 |
# File 'lib/direction.rb', line 32 def query() Direction.define_methods(self, ) do |, accessor| %{ def #{}(*args, &block) #{accessor}.__send__(:#{}, *args, &block) end } end end |