I am using Ruby on Rails 3.2.2. I am implementing a module and including that in a my class by using the RoR ActiveSupport::Concern feature. It makes available the included do ... end block making code stated inside that to be executed in the class context of the class where the module is included.

My doubt is: What should I not include in the included do ... end block? That is, for instance, is it a "common" / "good" practice to make the following?

module MyModule
  extend ActiveSupport::Concern

  class MyModuleClass
    attr_accessor :attr1, :attr2, :attr3

    def initialize(attrs)
     @attr1 = attrs[:attr1]
     @attr2 = attrs[:attr2]
     @attr3 = attrs[:attr3]
    end
  end

  included do
    @my_module_class = MyModuleClass.new(some_attrs)
  end
end

More, will be the @my_module_class variable available as an attribute in the including class of MyModule (BTW: I would like to make the @my_module_class to be "visible" only internally to MyModule since it is intended to be used only in that module)? Are there some "advanced" examples or tutorials on how to handle situations like that I am trying to instantiate in the included do ... end block of the above code? What do you advice about?

Edit
Report