Sha256: 0ff2735c675d93538f00115d5b221d38affc4cb791f5abd72e755a092a3f67a3

Contents?: true

Size: 570 Bytes

Versions: 30

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/base'

module Mutils
  # 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
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mutils-0.2.37 lib/generators/mutils/serializer_generator.rb
mutils-0.2.36 lib/generators/mutils/serializer_generator.rb
mutils-0.2.35 lib/generators/mutils/serializer_generator.rb
mutils-0.2.34 lib/generators/mutils/serializer_generator.rb
mutils-0.2.33 lib/generators/mutils/serializer_generator.rb
mutils-0.2.32 lib/generators/mutils/serializer_generator.rb
mutils-0.2.31 lib/generators/mutils/serializer_generator.rb
mutils-0.2.30 lib/generators/mutils/serializer_generator.rb
mutils-0.2.29 lib/generators/mutils/serializer_generator.rb
mutils-0.2.28 lib/generators/mutils/serializer_generator.rb