I am DRYing up some code. Earlier I was creating modules and calling a
method in the module.
I am trying to avoid that so merely requiring the file, should execute
the code within the module – at the instance level. However, what I
find is that the code is executed at the module level. IS there any way
i can achieve this.
e.g.
module Bindings
bind_key(KEY_UP, :prev_row)
more follow
end
include Bindings
Other file:
class Foo
def map_keys
require ‘myproj/bindings’
other bindings
bind_key(KEY_DEL, :delete)
end
def bind_key *args
end
end
Now, when I run this, I wish bind_key in Bindings to work at the
instance level of a Foo object.
Is this possible, or do I have to call a method from Foo ?
thx, rkumar