Sha256: a7a905813f783411340a751fa83eb192f6c5c8dbe9f7e825c6e3639121b3b235

Contents?: true

Size: 1.08 KB

Versions: 15

Compression:

Stored size: 1.08 KB

Contents

module Shoulda # :nodoc:
  module ActionController # :nodoc:
    module Helpers # :nodoc:
      private # :enddoc:

      SPECIAL_INSTANCE_VARIABLES = %w{
        _cookies
        _flash
        _headers
        _params
        _request
        _response
        _session
        action_name
        before_filter_chain_aborted
        cookies
        flash
        headers
        ignore_missing_templates
        logger
        params
        request
        request_origin
        response
        session
        template
        template_class
        template_root
        url
        variables_added
      }.map(&:to_s)

      def instantiate_variables_from_assigns(*names, &blk)
        old = {}
        names = (@response.template.assigns.keys - SPECIAL_INSTANCE_VARIABLES) if names.empty?
        names.each do |name|
          old[name] = instance_variable_get("@#{name}")
          instance_variable_set("@#{name}", assigns(name.to_sym))
        end
        blk.call
        names.each do |name|
          instance_variable_set("@#{name}", old[name])
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
Flamefork-shoulda-2.10.1 lib/shoulda/action_controller/helpers.rb
Flamefork-shoulda-2.10.2 lib/shoulda/action_controller/helpers.rb
francois-shoulda-2.10.1 lib/shoulda/action_controller/helpers.rb
gnip-gnip-1.1.1 test/lib/shoulda/action_controller/helpers.rb
technicalpickles-shoulda-2.10.0 lib/shoulda/action_controller/helpers.rb
thoughtbot-shoulda-2.10.0 lib/shoulda/action_controller/helpers.rb
thoughtbot-shoulda-2.10.1 lib/shoulda/action_controller/helpers.rb
thoughtbot-shoulda-2.9.2 lib/shoulda/action_controller/helpers.rb
shoulda-2.9.2 lib/shoulda/action_controller/helpers.rb
shoulda-2.10.0 lib/shoulda/action_controller/helpers.rb
shoulda-2.10.1 lib/shoulda/action_controller/helpers.rb
gnip-0.4.2 test/lib/shoulda/action_controller/helpers.rb
gnip-1.0.0 test/lib/shoulda/action_controller/helpers.rb
gnip-1.1.1 test/lib/shoulda/action_controller/helpers.rb
gnip-1.1.2 test/lib/shoulda/action_controller/helpers.rb