Sha256: de51c0482eaecb5e2d7db5e993688878155df304fe6317408df06cc91113a016

Contents?: true

Size: 633 Bytes

Versions: 39

Compression:

Stored size: 633 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

39 entries across 39 versions & 1 rubygems

Version Path
lipsiadmin-5.1.6 lib/utils/literal.rb
lipsiadmin-5.1.5 lib/utils/literal.rb
lipsiadmin-5.1.4 lib/utils/literal.rb
lipsiadmin-5.1.3 lib/utils/literal.rb
lipsiadmin-5.1.2 lib/utils/literal.rb
lipsiadmin-5.1.1 lib/utils/literal.rb
lipsiadmin-5.1.0 lib/utils/literal.rb
lipsiadmin-5.0.9 lib/utils/literal.rb
lipsiadmin-5.0.8 lib/utils/literal.rb
lipsiadmin-5.0.7 lib/utils/literal.rb
lipsiadmin-5.0.6 lib/utils/literal.rb
lipsiadmin-5.0.5 lib/utils/literal.rb
lipsiadmin-5.0.4 lib/utils/literal.rb
lipsiadmin-4.1.8 lib/utils/literal.rb
lipsiadmin-5.0.0 lib/utils/literal.rb
lipsiadmin-5.0.1 lib/utils/literal.rb
lipsiadmin-5.0.2 lib/utils/literal.rb
lipsiadmin-5.0.3 lib/utils/literal.rb
lipsiadmin-3.3.1 lib/utils/literal.rb
lipsiadmin-3.0 lib/utils/literal.rb