Sha256: a95cded1595bb4dc1ffb494b93ffcf821b5cae2cf0dc2a3e9af3eefa0711f3b0

Contents?: true

Size: 816 Bytes

Versions: 13

Compression:

Stored size: 816 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, context = {})
          send(:"generate_#{code.type}",
            code)

        rescue NoMethodError => e
          if e.name == :"_generate_code_#{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

13 entries across 13 versions & 1 rubygems

Version Path
liquidscript-0.4.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.4.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.3.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.3.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.2.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.2.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.5 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.4 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.3 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.2 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.1 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.1.0 lib/liquidscript/generator/base/replacements.rb
liquidscript-0.0.1 lib/liquidscript/generator/base/replacements.rb