Sha256: ff7a9486bbad6b9c82f7d7a38b94b83ddd6b19d3093bb1e14e9e49d567d1ec10

Contents?: true

Size: 959 Bytes

Versions: 4

Compression:

Stored size: 959 Bytes

Contents

module Rails
  module Generators
    class TransFormGenerator < NamedBase
      source_root File.expand_path('../templates', __FILE__)
      check_class_collision

      class_option :parent, type: :string, desc: 'The parent class for the generated form model'

      def create_form_file
        template 'trans_form.rb', File.join('app/trans_forms', class_path, "#{file_name}.rb")
      end

      hook_for :test_framework

    private

      def parent_class_name
        options.fetch('parent') do
          begin
            require 'application_trans_form'
            ApplicationTransForm
          rescue LoadError
            'TransForms::FormBase'
          end
        end
      end

      # Rails 3.0.X compatibility, copied from https://github.com/jnunemaker/mongomapper/pull/385/files#L1R32
      unless methods.include?(:module_namespacing)
        def module_namespacing
          yield if block_given?
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trans_forms-0.2.2 lib/generators/rails/trans_form_generator.rb
trans_forms-0.2.1 lib/generators/rails/trans_form_generator.rb
trans_forms-0.2.0 lib/generators/rails/trans_form_generator.rb
trans_forms-0.1.0 lib/generators/rails/trans_form_generator.rb