Sha256: 8ee61bddd12dcb1a992af4f5df8ac4a1219b4098537a73a831a29e316d6f9ff3

Contents?: true

Size: 879 Bytes

Versions: 24

Compression:

Stored size: 879 Bytes

Contents

require "rails/generators"
require "generators/statesman/generator_helpers"

module Statesman
  class ActiveRecordTransitionGenerator < Rails::Generators::Base
    include Statesman::GeneratorHelpers

    desc "Create an ActiveRecord-based transition model"\
         "with the required attributes"

    argument :parent, type: :string, desc: "Your parent model name"
    argument :klass,  type: :string, desc: "Your transition model name"

    source_root File.expand_path('../templates', __FILE__)

    def create_model_file
      template("create_migration.rb.erb", migration_file_name)
      template("active_record_transition_model.rb.erb", model_file_name)
    end

    private

    def migration_file_name
      "db/migrate/#{next_migration_number}_create_#{table_name}.rb"
    end

    def rails_4?
      Rails.version.split(".").map(&:to_i).first >= 4
    end
  end
end

Version data entries

24 entries across 23 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/statesman-1.3.1/lib/generators/statesman/active_record_transition_generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/statesman-2.0.1/lib/generators/statesman/active_record_transition_generator.rb
statesman-2.0.1 lib/generators/statesman/active_record_transition_generator.rb
statesman-2.0.0 lib/generators/statesman/active_record_transition_generator.rb
statesman-2.0.0.rc1 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.3.1 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.3.0 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.5 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.4 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.3 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.2 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.1 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.2.0 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.1.0 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.0.0 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.0.0.beta2 lib/generators/statesman/active_record_transition_generator.rb
statesman-1.0.0.beta1 lib/generators/statesman/active_record_transition_generator.rb
statesman-0.8.3 lib/generators/statesman/active_record_transition_generator.rb
statesman-0.8.2 lib/generators/statesman/active_record_transition_generator.rb
statesman-0.8.1 lib/generators/statesman/active_record_transition_generator.rb