Sha256: 5c12539a0a04b989cab20a45454cb048182f24c4adee9a39866e40a2fb7ec013

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

module Munge
  module Core
    class TransformScopeFactory
      def initialize(source_path,
                     layouts_path,
                     global_data,
                     source,
                     helper_container)
        @source_path      = source_path
        @layouts_path     = layouts_path
        @global_data      = global_data
        @source           = source
        @helper_container = helper_container
      end

      def create(load_helpers = true)
        scope = Munge::Transformer::Tilt::Scope.new(
          @source_path,
          @layouts_path,
          @global_data,
          @source
        )

        if load_helpers
          extend_with_helpers(scope)
        end

        scope
      end

      private

      def extend_with_helpers(scope)
        Munge::Helper.constants
          .map  { |sym| @helper_container.const_get(sym) }
          .each { |helper| scope.extend(helper) }

        scope
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
munge-0.2.0 lib/munge/core/transform_scope_factory.rb