Sha256: 355460a8d37ba3db107ba52ddaf311cbe270cdab10b989f2132e1cd6d3c63d87

Contents?: true

Size: 595 Bytes

Versions: 4

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

module Rating
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    desc 'Creates Rating migration'

    def create_migration
      template 'db/migrate/create_rating_table.rb', "db/migrate/#{timestamp(0)}_create_rating_table.rb"
      template 'db/migrate/create_rate_table.rb', "db/migrate/#{timestamp(1)}_create_rate_table.rb"
    end

    private

    def time
      @time ||= Time.current
    end

    def timestamp(seconds)
      (time + seconds.seconds).strftime '%Y%m%d%H%M%S'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rating-0.8.0 lib/generators/rating/install_generator.rb
rating-0.7.0 lib/generators/rating/install_generator.rb
rating-0.6.0 lib/generators/rating/install_generator.rb
rating-0.5.0 lib/generators/rating/install_generator.rb