Sha256: 94534a89bfdcf1a78581a1c975b9c955156be29031239753946c56dc7d850073

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module FactoryBot
  module Generators
    class TransactionGenerator < Rails::Generators::NamedBase
      source_root File.expand_path('templates', __dir__)

      def create_transaction_factory
        template 'transactions.rb.erb', "spec/factories/#{module_path}/#{file_name}.rb"
      end

      def file_name
        class_name.underscore.pluralize
      end

      def qualified_class_name
        "#{module_name}::#{class_name}"
      end

      def class_name
        "#{name.to_s.classify.chomp('Transaction')}Transaction"
      end

      def module_name
        module_path.classify
      end

      def module_path
        'ledger'
      end

      def factory_name
        class_name.underscore
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generalis-0.1.0 lib/generators/factory_bot/transaction_generator.rb