responders.rb 1.1 KB

123456789101112131415161718192021222324252627282930
  1. require 'action_controller/base'
  2. module Responders
  3. autoload :FlashResponder, 'responders/flash_responder'
  4. autoload :HttpCacheResponder, 'responders/http_cache_responder'
  5. autoload :CollectionResponder, 'responders/collection_responder'
  6. require 'responders/controller_method'
  7. class Railtie < ::Rails::Railtie
  8. config.responders = ActiveSupport::OrderedOptions.new
  9. config.responders.flash_keys = [ :notice, :alert ]
  10. config.responders.namespace_lookup = false
  11. if config.respond_to?(:app_generators)
  12. config.app_generators.scaffold_controller = :responders_controller
  13. else
  14. config.generators.scaffold_controller = :responders_controller
  15. end
  16. # Add load paths straight to I18n, so engines and application can overwrite it.
  17. require 'active_support/i18n'
  18. I18n.load_path << File.expand_path('../responders/locales/en.yml', __FILE__)
  19. initializer "responders.flash_responder" do |app|
  20. Responders::FlashResponder.flash_keys = app.config.responders.flash_keys
  21. Responders::FlashResponder.namespace_lookup = app.config.responders.namespace_lookup
  22. end
  23. end
  24. end