Sha256: 298bdc3f755e7a40bf58bcf4687fd051bfb1f7ba08aad10f0c811595651f57ce

Contents?: true

Size: 872 Bytes

Versions: 56

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

require_relative "../../lib/plutonium_generators"

module Pu
  module Field
    class InputGenerator < Rails::Generators::Base
      include PlutoniumGenerators::Generator

      source_root File.expand_path("templates", __dir__)

      desc "Generates a field input"

      argument :name

      def start
        in_root do
          template "input.rb", "app/plutonium/fields/inputs/#{name.underscore}_input.rb"
          insert_into_file "config/initializers/plutonium.rb", registration_statement, after: /.*# Register components here.*\n/
        end
      rescue => e
        exception "#{self.class} failed:", e
      end

      private

      def registration_statement
        indent "Plutonium::Core::Fields::Inputs::Factory.map_type :#{name.underscore}, to: Fields::Inputs::#{name.camelize}Input\n", 2
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
plutonium-0.19.2 lib/generators/pu/field/input/input_generator.rb
plutonium-0.19.1 lib/generators/pu/field/input/input_generator.rb
plutonium-0.19.0 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.8 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.7 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.6 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.5 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.4 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.3 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.2 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.1 lib/generators/pu/field/input/input_generator.rb
plutonium-0.18.0 lib/generators/pu/field/input/input_generator.rb
plutonium-0.16.5 lib/generators/pu/field/input/input_generator.rb
plutonium-0.16.4 lib/generators/pu/field/input/input_generator.rb
plutonium-0.16.3 lib/generators/pu/field/input/input_generator.rb
plutonium-0.16.1 lib/generators/pu/field/input/input_generator.rb
plutonium-0.16.0 lib/generators/pu/field/input/input_generator.rb
plutonium-0.15.24 lib/generators/pu/field/input/input_generator.rb
plutonium-0.15.23 lib/generators/pu/field/input/input_generator.rb
plutonium-0.15.22 lib/generators/pu/field/input/input_generator.rb