Sha256: 97e94a4b725c7d12ac2641419e6c5538017fdfd842b111c169cfde52d89296b4

Contents?: true

Size: 796 Bytes

Versions: 32

Compression:

Stored size: 796 Bytes

Contents

module Liquidscript
  module Generator
    class Base
      module Replacements

        # Replace a code with a string.  This uses the replacement
        # definitions that are a part of the class.
        #
        # @param code [ICR::Code, #type]
        # @param context [Hash]
        def replace(code)
          send(:"generate_#{code.type}",
            code)

        rescue NoMethodError => e
          if e.name == :"generate_#{code.type}"
            raise InvalidCodeError.new(code.type)
          else
            raise
          end
        end

        # Access to the replacements method on the class.
        #
        # @see [ClassMethods#replacements]
        # @return [Hash]
        def replacements
          self.class.replacements
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
liquidscript-0.10.4 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.10.3 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.10.2 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.10.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.10.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.9.2 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.9.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.9.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.8.2 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.8.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.8.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.12 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.11 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.10 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.9 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.8 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.7 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.6 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.5 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.7.4 lib/liquidscript/generator/base/replacements.rb