Class Rails::Generator::Spec
In: vendor/rails/railties/lib/rails_generator/spec.rb
Parent: Object

A spec knows where a generator was found and how to instantiate it. Metadata include the generator‘s name, its base path, and the source which yielded it (PathSource, GemPathSource, etc.)

Methods

class_file   class_name   klass   new  

Attributes

name  [R] 
path  [R] 
source  [R] 

Public Class methods

[Source]

    # File vendor/rails/railties/lib/rails_generator/spec.rb, line 9
 9:       def initialize(name, path, source)
10:         @name, @path, @source = name, path, source
11:       end

Public Instance methods

[Source]

    # File vendor/rails/railties/lib/rails_generator/spec.rb, line 24
24:       def class_file
25:         "#{path}/#{name}_generator.rb"
26:       end

[Source]

    # File vendor/rails/railties/lib/rails_generator/spec.rb, line 28
28:       def class_name
29:         "#{name.camelize}Generator"
30:       end

Look up the generator class. Require its class file, find the class in ObjectSpace, tag it with this spec, and return.

[Source]

    # File vendor/rails/railties/lib/rails_generator/spec.rb, line 15
15:       def klass
16:         unless @klass
17:           require class_file
18:           @klass = lookup_class
19:           @klass.spec = self
20:         end
21:         @klass
22:       end

[Validate]