T
T. Onoma
I'm having one of Those mornings!
I'm not sure how to overcome the syntax error this causes:
class Module
def cast_writer(name,cast)
if cast.kind_of?(Proc) or cast.kind_of?(Method)
define_method(name) { |x| instance_eval("@#{name}") = cast.call(x) }
end
end
end
syntax error (SyntaxError)
define_method(name) { |x| instance_eval("@#{name}") = cast.call(x) }
^
The problem I see is that @name has to be provided as a string, while cast
cannot be.
Thanks,
T.
I'm not sure how to overcome the syntax error this causes:
class Module
def cast_writer(name,cast)
if cast.kind_of?(Proc) or cast.kind_of?(Method)
define_method(name) { |x| instance_eval("@#{name}") = cast.call(x) }
end
end
end
syntax error (SyntaxError)
define_method(name) { |x| instance_eval("@#{name}") = cast.call(x) }
^
The problem I see is that @name has to be provided as a string, while cast
cannot be.
Thanks,
T.