lib/eeny-meeny/railtie.rb in eeny-meeny-1.0.0 vs lib/eeny-meeny/railtie.rb in eeny-meeny-2.0.0

- old
+ new

@@ -1,27 +1,28 @@ +require 'eeny-meeny' require 'eeny-meeny/experiment_helper' require 'eeny-meeny/middleware' module EenyMeeny class Railtie < Rails::Railtie config.eeny_meeny = ActiveSupport::OrderedOptions.new - # default config values. these can be changed in the rails environment configuration. - config.eeny_meeny.experiments = [] - config.eeny_meeny.secure = true - config.eeny_meeny.secret = '9fc8b966eca7d03d55df40c01c10b8e02bf1f9d12d27b8968d53eb53e8c239902d00bf6afae5e726ce1111159eeb2f8f0e77233405db1d82dd71397f651a0a4f' - config.eeny_meeny.cookies = ActiveSupport::OrderedOptions.new - config.eeny_meeny.cookies.path = '/' - config.eeny_meeny.cookies.same_site = :strict - initializer 'eeny_meeny.initialize' do |app| + initializer 'eeny_meeny.configure' do |app| + # Configrue EenyMeeny (defaults set in eeny_meeny.rb) + EenyMeeny.configure do |config| + config.cookies = app.config.eeny_meeny[:cookies] if app.config.eeny_meeny.has_key?(:cookies) + config.experiments = app.config.eeny_meeny[:experiments] if app.config.eeny_meeny.has_key?(:experiments) + config.secret = app.config.eeny_meeny[:secret] if app.config.eeny_meeny.has_key?(:secret) + config.secure = app.config.eeny_meeny[:secure] if app.config.eeny_meeny.has_key?(:secure) + end + # Include Helpers in ActionController and ActionView ActionController::Base.send :include, EenyMeeny::ExperimentHelper ActionView::Base.send :include, EenyMeeny::ExperimentHelper + # Insert Middleware + app.middleware.insert_before 'ActionDispatch::Cookies', EenyMeeny::Middleware + end - app.middleware.insert_before 'ActionDispatch::Cookies', EenyMeeny::Middleware, - config.eeny_meeny.experiments, - config.eeny_meeny.secure, - config.eeny_meeny.secret, - config.eeny_meeny.cookies.path, - config.eeny_meeny.cookies.same_site + rake_tasks do + load 'tasks/cookie.rake' end end end