Sha256: 851c896253728ae4fe920e4a16532a57536b2983d4eb0dacd9a164092667ebc9

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

module BasicPresenter
  module Generators
    class PresenterGenerator < Rails::Generators::NamedBase

      check_class_collision suffix: "Presenter"

      def create_presenter_file
        create_file "app/presenters/#{file_name}_presenter.rb", <<~FILE
  class #{class_name}Presenter < ApplicationPresenter
    presents :#{plural_name.singularize}

    # Methods delegated to Presented Class #{class_name} object's #{plural_name.singularize}
    @delegation_methods = []

    delegate *@delegation_methods, to: :#{plural_name.singularize}

    # Start the methods
    # def full_name
    #   first_name + last_name
    # end
  end
        FILE
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basic_presenter-0.0.4 lib/generators/basic_presenter/presenter_generator.rb