I'm making a small program for Rails that includes some of my methods I've built inside of a module inside of the ApplicationHelper
module. Here's an example:
module Helper def time Time.now.year end end module ApplicationHelper # Inherit from Helper here... end
I know that ApplicationHelper < Helper
and include Helper
would work in the context of a class, but what would you use for module-to-module inherits? Thanks.
In fact you can define a module inside of another module, and then include it within the outer one.
so ross$ cat >> mods.rb module ApplicationHelper module Helper def time Time.now.year end end include Helper end class Test include ApplicationHelper def run p time end self end.new.run so ross$ ruby mods.rb 2012
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With