Sha256: 8b164f0353d30762e3adf6aba3d8d22f80e82263be000f1298f387bb1a7afcd1

Contents?: true

Size: 910 Bytes

Versions: 6

Compression:

Stored size: 910 Bytes

Contents

module Stationed
  module Generators
    module Plugins
      module Responders
        def self.prepended(base)
          base.class_option :responders,
            type: :boolean,
            default: true,
            desc: 'Add and configure Responders gem for DRY controllers'
        end

        def finish_template
          return super unless options[:responders]
          gem 'responders'
          copy_file 'application_responder.rb', 'lib/application_responder.rb'

          inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController' do
            <<-RUBY
  self.responder = ApplicationResponder
  respond_to :html

            RUBY
          end

          application do
            <<-RUBY
# Enable auto-loading from ./lib
    config.autoload_paths << Rails.root.join('lib')
            RUBY
          end
          super
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stationed-0.6.0 lib/stationed/generators/plugins/responders.rb
stationed-0.5.0 lib/stationed/generators/plugins/responders.rb
stationed-0.4.0 lib/stationed/generators/plugins/responders.rb
stationed-0.3.0 lib/stationed/generators/plugins/responders.rb
stationed-0.2.0 lib/stationed/generators/plugins/responders.rb
stationed-0.1.0 lib/stationed/generators/plugins/responders.rb