Class: Auth::Generators::MigrationGenerator
- Inherits:
-
Rails::Generator::NamedBase
- Object
- Rails::Generator::NamedBase
- Auth::Generators::MigrationGenerator
- Defined in:
- lib/auth/generators/migration_generator.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, options = {}) ⇒ MigrationGenerator
constructor
A new instance of MigrationGenerator.
- #manifest ⇒ Object
- #spec ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(model, options = {}) ⇒ MigrationGenerator
Returns a new instance of MigrationGenerator.
4 5 6 7 8 |
# File 'lib/auth/generators/migration_generator.rb', line 4 def initialize(model, = {}) @model = model args = [ model.name ] super(args, ) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
2 3 4 |
# File 'lib/auth/generators/migration_generator.rb', line 2 def model @model end |
Instance Method Details
#manifest ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/auth/generators/migration_generator.rb', line 10 def manifest record do |m| m.directory "db/migrate" mg_version = 0 Auth.behavior_classes.each do |behavior| behavior.migrations.each do |file_name| fn_with_ext = file_name[/\.([^\.]+)$/] ? file_name : "#{file_name}.rb" mg_version += 1 mg_version_s = mg_version.to_s.rjust(3, '0') m.template File.join("migrations", fn_with_ext), File.join("db/migrate/#{mg_version_s}_#{fn_with_ext}") end end end end |
#spec ⇒ Object
29 30 31 |
# File 'lib/auth/generators/migration_generator.rb', line 29 def spec @spec ||= Rails::Generator::Spec.new("sparkly_migration", File.join(Auth.path, "auth/generators"), nil) end |
#table_name ⇒ Object
25 26 27 |
# File 'lib/auth/generators/migration_generator.rb', line 25 def table_name model && model.target ? model.target.table_name : super end |