Sha256: 52b4032f515127c624cf656e7235f08c5ea2ea39fc4297e2fb5a824e94984b9f

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'rails/generators'

class CommonRepositoryModel::CollectionGenerator < Rails::Generators::NamedBase
  check_class_collision
  source_root File.expand_path('../templates', __FILE__)
  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

1 entries across 1 versions & 1 rubygems

Version Path
common_repository_model-0.1.0 lib/generators/common_repository_model/collection/collection_generator.rb