Sha256: 0149e69258f4cb08e51f89ca0d7bcb9e927b4aaf5635b4135844045d807d3c7f

Contents?: true

Size: 882 Bytes

Versions: 3

Compression:

Stored size: 882 Bytes

Contents

class I18nAttributes::ReviseModelGenerator < Rails::Generators::Base
  source_root File.expand_path('../templates', __FILE__)

  class_option :orm, :required => false, :default => "active_record"

  include ::VkillGemsMethods::Rails::Generators::Base
  ::ActiveRecord::Base.send :include, ::VkillGemsMethods::ActiveRecord::Base

  include I18nAttributes::GeneratorHelpers

  SUPPORTED_ORMS = %w(active_record)

  def create_model_i18n_file

    orm = options.orm.to_s

    say_error "#{orm} [not found]" unless SUPPORTED_ORMS.include? orm

    ::ActiveRecord::Base.models do |model, columns|
      ::I18nAttributes::Configuration.locales.each do |locale|
        create_file "config/locales/model_#{ locale }/#{ model.name.underscore }.yml",
                generate_yaml_file_data(locale, model.model_name.underscore, model.model_name, columns, orm)
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n_attributes-0.1.2 lib/generators/i18n_attributes/revise_model/revise_model_generator.rb
i18n_attributes-0.1.1.1 lib/generators/i18n_attributes/revise_model/revise_model_generator.rb
i18n_attributes-0.1.1 lib/generators/i18n_attributes/revise_model/revise_model_generator.rb