Sha256: 7e1b5ade348132517f8bad0db251d4e640ed39c92a33c6ff30526397f63a0da4

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'rails/generators'

class CommonRepositoryModel::CollectionGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
  class_option :test_dir, :type => :string, :default => "spec/factories", :desc => "The directory where the factories should go"

  def create_collection
    template(
      'collection.rb.erb',
      File.join('app/repository_models/', "#{file_name}.rb")
    )
  end

  def create_service_spec
    template(
      'collection_spec.rb.erb',
      File.join('spec/repository_models/', "#{file_name}_spec.rb")
    )
  end

  def create_fixture_file
    template 'collection_factory.rb.erb', File.join(options[:test_dir], "#{file_name}_factory.rb")
  end

  def create_serializer
    template(
      'collection_serializer.rb.erb',
      File.join('app/repository_serializers/', "#{file_name}_serializer.rb")
    )
  end

  def create_serializer_spec
    template(
      'collection_serializer_spec.rb.erb',
      File.join('spec/repository_serializers/', "#{file_name}_serializer_spec.rb")
    )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
common_repository_model-0.0.9 lib/generators/common_repository_model/collection/collection_generator.rb
common_repository_model-0.0.8 lib/generators/common_repository_model/collection/collection_generator.rb
common_repository_model-0.0.7 lib/generators/common_repository_model/collection/collection_generator.rb