Sha256: 0fb23ab3cd7190ed1bfc93f02392ba737a143f0a90b9ae5d3f717780caa63470

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

module Prospecto
  class PresenterGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)

    def write_presenter
      template 'presenter.rb', "app/presenters/#{file_name_root}_presenter.rb"
    end

    def write_presenter_spec
      template 'presenter_spec.rb', "spec/presenters/#{file_name_root}_presenter_spec.rb"
    end

    protected

    def file_name_root
      name.underscore
    end

    def class_name
      name.camelize
    end

    def single_name
      name.underscore.singularize
    end

    def base_class
      if File.exists?(Rails.root.join("app/presenters/application_presenter.rb"))
        "ApplicationPresenter"
      else
        "Prospecto::PresenterView"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prospecto-0.2.3 lib/generators/prospecto/presenter/presenter_generator.rb
prospecto-0.2.2 lib/generators/prospecto/presenter/presenter_generator.rb
prospecto-0.2.1 lib/generators/prospecto/presenter/presenter_generator.rb
prospecto-0.2.0 lib/generators/prospecto/presenter/presenter_generator.rb