Sha256: f1e070507538653d200c3aa2acc6fdda62526b17f5649661a33f354559e895c4

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

require 'generators/transponder'

module Transponder
  module Generators
    class PresenterGenerator < Base
      class_option :module_name, type: :string, aliases: '-m', default: 'application'

      def add_presenter
        presenter_path = File.join(javascripts_path, options[:module_name], "presenters/#{file_name.downcase}_presenter.coffee")
        template "_presenter.coffee", presenter_path
      end

      def presenter_class_name
        "#{options[:module_name].camelize}.Presenters.#{file_name.classify}Presenter"
      end

      def add_presenter_to_boot
        boot_file = File.join(javascripts_path, options[:module_name], 'initializers/boot.coffee')
        insert_into_file boot_file, 
                         "new #{presenter_class_name}()\n",
                         after: "# presenters\n"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
transponder-0.9.6 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.9.5 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.9.4 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.9.3 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.9.2 lib/generators/transponder/presenter/presenter_generator.rb