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-1.3.3 lib/generators/mutils/serializer_generator.rb
mutils-1.3.2 lib/generators/mutils/serializer_generator.rb
mutils-1.3.1 lib/generators/mutils/serializer_generator.rb
mutils-1.3.0 lib/generators/mutils/serializer_generator.rb
mutils-1.2.6 lib/generators/mutils/serializer_generator.rb
mutils-1.2.5 lib/generators/mutils/serializer_generator.rb
mutils-1.2.2 lib/generators/mutils/serializer_generator.rb
mutils-1.2.1 lib/generators/mutils/serializer_generator.rb
mutils-1.2.0 lib/generators/mutils/serializer_generator.rb
mutils-1.1.8 lib/generators/mutils/serializer_generator.rb
mutils-1.1.7 lib/generators/mutils/serializer_generator.rb
mutils-1.1.6 lib/generators/mutils/serializer_generator.rb
mutils-1.1.5 lib/generators/mutils/serializer_generator.rb
mutils-1.1.4 lib/generators/mutils/serializer_generator.rb
mutils-1.1.3 lib/generators/mutils/serializer_generator.rb
mutils-1.1.2 lib/generators/mutils/serializer_generator.rb
mutils-1.1.1 lib/generators/mutils/serializer_generator.rb
mutils-1.1.0 lib/generators/mutils/serializer_generator.rb
mutils-1.0.1 lib/generators/mutils/serializer_generator.rb
mutils-1.0.0 lib/generators/mutils/serializer_generator.rb