Class: Rails::Generator::NamedBase

Inherits:
Base show all
Defined in:
lib/rails_generator/base.rb

Overview

The base generator for named components: models, controllers, mailers, etc. The target name is taken as the first argument and inflected to singular, plural, class, file, and table forms for your convenience. The remaining arguments are aliased to actions for controller and mailer convenience.

If no name is provided, the generator raises a usage error with content optionally read from the USAGE file in the generator’s base path.

See Rails::Generator::Base for a discussion of Manifests and Commands.

Instance Attribute Summary collapse

Attributes inherited from Base

#args, #destination_root, #source_root

Instance Method Summary collapse

Methods inherited from Base

#destination_path, #manifest, #source_path

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ NamedBase

Returns a new instance of NamedBase.



153
154
155
156
157
158
159
160
161
162
# File 'lib/rails_generator/base.rb', line 153

def initialize(runtime_args, runtime_options = {})
  super

  # Name argument is required.
  usage if runtime_args.empty?

  @args = runtime_args.dup
  base_name = @args.shift
  assign_names!(base_name)
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



147
148
149
# File 'lib/rails_generator/base.rb', line 147

def class_name
  @class_name
end

#class_nestingObject (readonly)

Returns the value of attribute class_nesting.



148
149
150
# File 'lib/rails_generator/base.rb', line 148

def class_nesting
  @class_nesting
end

#class_nesting_depthObject (readonly)

Returns the value of attribute class_nesting_depth.



148
149
150
# File 'lib/rails_generator/base.rb', line 148

def class_nesting_depth
  @class_nesting_depth
end

#class_pathObject (readonly)

Returns the value of attribute class_path.



148
149
150
# File 'lib/rails_generator/base.rb', line 148

def class_path
  @class_path
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



148
149
150
# File 'lib/rails_generator/base.rb', line 148

def file_path
  @file_path
end

#nameObject (readonly)

Returns the value of attribute name.



147
148
149
# File 'lib/rails_generator/base.rb', line 147

def name
  @name
end

#plural_nameObject (readonly) Also known as: table_name

Returns the value of attribute plural_name.



147
148
149
# File 'lib/rails_generator/base.rb', line 147

def plural_name
  @plural_name
end

#singular_nameObject (readonly) Also known as: file_name

Returns the value of attribute singular_name.



147
148
149
# File 'lib/rails_generator/base.rb', line 147

def singular_name
  @singular_name
end