Rails::Generator::NamedBase
# File lib/activemessaging/named_base.rb, line 22 def assign_names!(name) @name = name base_name, @class_path, @file_path, @class_nesting, @class_nesting_depth = extract_modules(@name) @class_name_without_nesting, @singular_name, @plural_name = inflect_names(base_name) if @class_nesting.empty? @class_name = @class_name_without_nesting else @table_name = @class_nesting.underscore << "_" << @table_name @class_name = "#{@class_nesting}::#{@class_name_without_nesting}" end end
Extract modules from filesystem-style or ruby-style path:
good/fun/stuff Good::Fun::Stuff
produce the same results.
# File lib/activemessaging/named_base.rb, line 38 def extract_modules(name) modules = name.include?('/') ? name.split('/') : name.split('::') name = modules.pop path = modules.map { |m| m.underscore } file_path = (path + [name.underscore]).join('/') nesting = modules.map { |m| m.camelize }.join('::') [name, path, file_path, nesting, modules.size] end
Generated with the Darkfish Rdoc Generator 2.