Class: Rails::Generators::NamedBase
- Defined in:
- lib/generators/ballot/standalone/support.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #class_name ⇒ Object
- #file_name ⇒ Object
-
#initialize(name) ⇒ NamedBase
constructor
A new instance of NamedBase.
- #plural_table_name ⇒ Object
Methods inherited from Base
desc, generator_name, #migration_template
Constructor Details
#initialize(name) ⇒ NamedBase
Returns a new instance of NamedBase.
39 40 41 |
# File 'lib/generators/ballot/standalone/support.rb', line 39 def initialize(name) @name = prepare_name(name) end |
Instance Method Details
#class_name ⇒ Object
47 48 49 |
# File 'lib/generators/ballot/standalone/support.rb', line 47 def class_name @name.gsub(/^(.)|_(.)/) { (Regexp.last_match(1) || Regexp.last_match(2)).upcase } end |
#file_name ⇒ Object
51 52 53 |
# File 'lib/generators/ballot/standalone/support.rb', line 51 def file_name @name end |
#plural_table_name ⇒ Object
43 44 45 |
# File 'lib/generators/ballot/standalone/support.rb', line 43 def plural_table_name "#{@name}s" end |