ruby module as collection of methods -


i have rails app loads lots of data java services. i'm writing module allow me populate select boxes data , i'm trying include these can reference them in views. here's module

module filteroptions   module select      def some_select      return "some information"     end   end end 

my idea include filteroptions in application_helper, , thought reference methods using select::some_select not case. have include filteroptions::select can reference method some_select on own. don't want though think it's bit confusing may not know some_select coming own module.

so, how write methods of module public static methods can include main module, , reference methods using sub-module namespace select::some_select

if define module methods within context of module itself, can called without import:

module filteroptions   module select     def self.some_select      return "some information"     end   end end  puts filteroptions::select.some_select # => "some information" 

it possible import 1 module, , not import next, refer name instead:

include filteroptions puts select.some_select # => "some information" 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -