Sha256: 41559e3f82be94067933ad8e44f6ff7964a8a3c8777e57c8d3d72bd60b129e45

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 Bytes

Contents

module Lipsiadmin
  module Utils
    # Returns an object whose to_json evaluates to code.
    # Use this to pass a literal JavaScript expression as an argument to another JavaScriptGenerator method.
    #
    #   Examples:
    #
    #     "function() { alert('test') }".to_l
    #
    module Literal
      # Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
      # expression as an argument to another JavaScriptGenerator method.
      #
      def to_literal
        ActiveSupport::JSON::Variable.new(self.to_s)
      end
      alias_method :to_l, :to_literal
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lipsiadmin-5.1.9 lib/utils/literal.rb
lipsiadmin-5.1.8 lib/utils/literal.rb
lipsiadmin-5.1.7 lib/utils/literal.rb