Friday, 15 April 2011

ruby on rails - Overriding parent's class method via super / yield + variables? -



ruby on rails - Overriding parent's class method via super / yield + variables? -

i have rails 3 app , have subclass inherits superclass. overload parent class' class method. i'm trying utilize super block, can access multiple variables in parent , vice versa?

example:

class parentclass class << self def method_to_override #blah blah before yield block yield resource if block_given? end end end class childclass < parentclass class << self def method_to_override super |resource| #code within block can utilize resource variable end end end end

how can pass more resource variable? tried including yield (variable1, variable2) if block_given? didn't work.

ruby-on-rails

No comments:

Post a Comment