A
Ara.T.Howard
i have this
jib:~ > cat a.rb
module M
def bar
@bar = 42
super
end
end
class Foo
attr :bar
def initialize
@bar = 'bar'
end
end
foo = Foo.new
p foo.bar
class Foo
include M # of course this acts as super - it does not override
end
p foo.bar
jib:~ > ruby a.rb
"bar"
"bar"
and i want it to print "bar", "42". i'm looking for a way to overide all of a
classes methods via a module (or some other trick) without needing to extend
individual objects and without simply opening up the class and redefining
everything. in otherwords a simple way to override a bunch of bundled methods
at once. it seems like this must be possible but my brain isn't firing on all
fours today...
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
jib:~ > cat a.rb
module M
def bar
@bar = 42
super
end
end
class Foo
attr :bar
def initialize
@bar = 'bar'
end
end
foo = Foo.new
p foo.bar
class Foo
include M # of course this acts as super - it does not override
end
p foo.bar
jib:~ > ruby a.rb
"bar"
"bar"
and i want it to print "bar", "42". i'm looking for a way to overide all of a
classes methods via a module (or some other trick) without needing to extend
individual objects and without simply opening up the class and redefining
everything. in otherwords a simple way to override a bunch of bundled methods
at once. it seems like this must be possible but my brain isn't firing on all
fours today...
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================