S
Simon Strandgaard
Often I need to pass variables from that scope in which I
extend an instance.. I wonder if it can be done simpler?
tree = TreeBuilder.new
node_rep = tree.lookup(3)
class << value
attr_accessor :future_input # is this necessary?
def test
@input = @future_input # is this necessary?
super
end
end
value.future_input = node_rep # is this necessary?
value.test
assert_equal(node_rep, value.output)
As you can see there is 3 lines which is dealing with passing a variable
from parent scope into the instance. I find this cumbersome.
Can it be done simpler ?
extend an instance.. I wonder if it can be done simpler?
tree = TreeBuilder.new
node_rep = tree.lookup(3)
class << value
attr_accessor :future_input # is this necessary?
def test
@input = @future_input # is this necessary?
super
end
end
value.future_input = node_rep # is this necessary?
value.test
assert_equal(node_rep, value.output)
As you can see there is 3 lines which is dealing with passing a variable
from parent scope into the instance. I find this cumbersome.
Can it be done simpler ?