Sha256: 42ce4186eec87a71ab193b4ac40dd66523af8cdbdb4e4f20d14489255f7fd46e

Contents?: true

Size: 535 Bytes

Versions: 4

Compression:

Stored size: 535 Bytes

Contents

module DeviseMasquerade
  module Controllers
    module Helpers
      def self.define_helpers(mapping)
        name = mapping.name

        class_eval <<-METHODS, __FILE__, __LINE__ + 1
          def masquerade_#{name}!
            return if params[:masquerade].blank?

            #{name} = #{name.to_s.classify}.find_by_masquerade_key(params[:masquerade])

            sign_in #{name} if #{name}
          end
        METHODS
      end
    end
  end
end

ActionController::Base.send(:include, DeviseMasquerade::Controllers::Helpers)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise_masquerade-0.0.4 lib/devise_masquerade/controllers/helpers.rb
devise_masquerade-0.0.3 lib/devise_masquerade/controllers/helpers.rb
devise_masquerade-0.0.2 lib/devise_masquerade/controllers/helpers.rb
devise_masquerade-0.0.1 lib/devise_masquerade/controllers/helpers.rb