Making a module inherit from another module in Ruby

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)