Sha256: 4660c2f167e0caa36362bf069ba788d65a759b94da1c7390ad3e4e7751627f27

Contents?: true

Size: 800 Bytes

Versions: 12

Compression:

Stored size: 800 Bytes

Contents

class RoadCrew::EngineSettingsController < ActionController::Base
  include Motorhead::Controller
  layout false

  def index
    @engine_settings = JSON.parse(cookies['road_crew_engine_settings'].presence || '{}')
    all_engine_names = Rails::Engine.subclasses.select {|e| e < Motorhead::Engine}.map {|e| e.parent.name} - ['RoadCrew']
    # enable by default
    (all_engine_names - @engine_settings.keys).each {|engine_name| @engine_settings[engine_name] = '1'}
  end

  def update_all
#     on, off = engines.partition {|k, v| v == '1'}.map {|a| a.map {|kv| kv.first}}
    engine_settings = JSON.parse(cookies['road_crew_engine_settings'].presence || '{}').merge params[:engine_setting]
    cookies['road_crew_engine_settings'] = engine_settings.to_json
    redirect_to request.referer
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
motorhead-0.4.1 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.4.0 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.9 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.8 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.7 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.6 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.5 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.4 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.3 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.2 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.1 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb
motorhead-0.3.0 lib/motorhead/road_crew/app/controllers/road_crew/engine_settings_controller.rb