Sha256: 44cca5b32a66a5a706c835c8a76a85ec1cfdecda5cf9a92e39e95d23ac1d4cc1

Contents?: true

Size: 507 Bytes

Versions: 6

Compression:

Stored size: 507 Bytes

Contents

# frozen_string_literal: true

module Bemer
  class CommonTemplate
    attr_reader :mode

    def initialize(mode)
      @mode = mode.to_s.sub('add_', '').to_sym
    end

    def apply!(node)
      case mode
      when Pipeline::REPLACE_MODE then replace!(node)
      when Pipeline::CONTENT_MODE then node.add_child_nodes
      else node.public_send(mode)
      end
    end

    protected

    def replace!(node)
      node.need_replace = true

      node.replacers << node.dup

      nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bemer-0.6.0 lib/bemer/common_template.rb
bemer-0.5.0 lib/bemer/common_template.rb
bemer-0.4.0 lib/bemer/common_template.rb
bemer-0.3.0 lib/bemer/common_template.rb
bemer-0.2.0 lib/bemer/common_template.rb
bemer-0.1.0 lib/bemer/common_template.rb