Sha256: 4bb89c7509e499d99a66f3b842075864afc408c7fb57648739b7daf8bd09a993

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/base'

# Class SerializerGenerator
class SerializerGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('templates', __dir__)

  argument :attributes, type: :array, default: [], banner: 'field field'
  def create_serializer_file
    template 'serializer.rb.tt', File.join('app', 'serializers', class_path, "#{file_name}_serializer.rb")
  end

  private

  def attributes_names
    attributes.map { |attribute| attribute.name.to_sym.inspect }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mutils-0.2.27 lib/generators/serializer/serializer_generator.rb