Class: ROM::Cassandra::Migrations::Generator
- Inherits:
-
Object
- Object
- ROM::Cassandra::Migrations::Generator
- Defined in:
- lib/rom/cassandra/migrations/generator.rb
Overview
Generates the migration with given name at the target folder
Class Method Summary collapse
-
.call(name, path) ⇒ String
Initializes and calls the generator at once.
Instance Method Summary collapse
-
#call ⇒ String
Generates the migration.
-
#initialize(name, path) ⇒ Generator
constructor
Initializes the generator with path to target folder and migration name.
Constructor Details
#initialize(name, path) ⇒ Generator
Initializes the generator with path to target folder and migration name
30 31 32 33 34 35 |
# File 'lib/rom/cassandra/migrations/generator.rb', line 30 def initialize(name, path) @path = path @name = Inflecto.underscore(name) @klass = Inflecto.camelize(name) @version = Time.new.strftime "%Y%m%d%H%M%S" end |
Class Method Details
.call(name, path) ⇒ String
Initializes and calls the generator at once
21 22 23 |
# File 'lib/rom/cassandra/migrations/generator.rb', line 21 def self.call(name, path) new(name, path).call end |
Instance Method Details
#call ⇒ String
Generates the migration
41 42 43 44 45 46 |
# File 'lib/rom/cassandra/migrations/generator.rb', line 41 def call FileUtils.mkdir_p path File.write target, content target end |