Sha256: ae19ca5e688302dff9ba93dfb884579adf187cf9d3a4a6dd4caf891d0a4173c8

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

module Alf
  module Tools

    # Converts `value` to a ruby literal
    #
    # This method is provided for code generation mechanisms used by Alf in
    # various places (such as .rash files). The to_ruby_literal contract is
    # such that the following invariant holds:
    #
    #     eval(to_ruby_literal(value)) == value
    #
    # This contract is ensured by Myrrha::ToRubyLiteral for various ruby values.
    # Myrrha delegates the job to `value.to_ruby_literal` provided this method 
    # exists. In such case, the implementation must be such that the invariant
    # above is met.
    #
    # In every case, an invocation to this method only makes sense provided that
    # `value` denotes a pure value, with the obvious semantics (from TTM).
    #
    # @param [Object] value any ruby object that denotes a pure value.
    # @return [String] a ruby literal for `value`
    def to_ruby_literal(value)
      ToRubyLiteral.apply(value)
    end

    # Myrrha rules for converting to ruby literals
    ToRubyLiteral = Myrrha::ToRubyLiteral.dup.append do
    end

  end # module Tools
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf/tools/to_ruby_literal.rb
alf-0.12.1 lib/alf/tools/to_ruby_literal.rb
alf-0.12.0 lib/alf/tools/to_ruby_literal.rb
alf-0.11.1 lib/alf/tools/to_ruby_literal.rb
alf-0.11.0 lib/alf/tools/to_ruby_literal.rb