Module: WithEmbeddedAssets::Mixin

Included in:
ViewHelpers
Defined in:
lib/with_embedded_assets/mixin.rb

Overview

This mixin declares the method that can be used to temporarily set embedded assets in a HTML compiled by ActionView on Rails.

Instance Method Summary collapse

Instance Method Details

#with_embedded_assetsObject

Activates the embedding of assets during the execution of a block.

After the block finishes the state of the automatic embedding is returned to its previous state before the method was called.

Parameters:

  • block

    The block to be executed with automatic embedding activated.

Returns:

  • (Object)

    The returned object of the block.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/with_embedded_assets/mixin.rb', line 10

def with_embedded_assets
  previous_state = WithEmbeddedAssets.enabled?
  WithEmbeddedAssets.enabled = true
  return_value = nil
  begin
    return_value = yield
  ensure
    WithEmbeddedAssets.enabled = previous_state
  end
  return_value
end