Module: Stationed::Generators::Plugins::Responders

Included in:
AppGenerator
Defined in:
lib/stationed/generators/plugins/responders.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
# File 'lib/stationed/generators/plugins/responders.rb', line 5

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

Instance Method Details

#finish_templateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stationed/generators/plugins/responders.rb', line 12

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