Sha256: eb6dff82a31483478619154c09a236d0f25112d575c650948166baae20402112

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true
require 'motorhead/engine'

module RoadCrew
  class Engine < ::Rails::Engine
    include Motorhead::Engine

    active_if { true }
    mount_at 'motorhead/road_crew'

    Motorhead::Engine::ClassMethods.class_eval do
      remove_possible_method :active?
      # overwrite active? to check cookie value as well
      def active?(controller)
        if (settings = controller.send(:cookies)['road_crew_engine_settings'])
          return false if JSON.parse(settings)[controller.class.parent.name] == '0'
        end
        controller.instance_eval(&@active_if)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motorhead-0.5.0 lib/motorhead/road_crew/lib/road_crew/engine.rb