Sha256: b398af35877a1b5b16ab4a7cd8c5d5a79dbf7e90189e5b18b77d226c6da4cf1a

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

require 'rails/generators/test_unit/model/model_generator'
require File.join(File.dirname(__FILE__), '../base')

module NestedScaffold
  module Generators
    module Model
      class TestUnitGenerator < ::TestUnit::Generators::ModelGenerator
        include ::NestedScaffold::Base

        source_root superclass.source_root

        def initialize(*)
          super

          unless attributes.map {|a| [a.name, a.type.to_s]}.include? [nested_parent_name, 'references']
            #DIRTY HACK add 'references' attribute
            attributes.insert 0, Rails::Generators::GeneratedAttribute.new(nested_parent_name, :references)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nested_scaffold-1.1.0 lib/generators/test_unit/model_generator.rb
nested_scaffold-1.0.0 lib/generators/test_unit/model_generator.rb