Sha256: e0210d5a2874d39a293add873005176c9304cbcb8ca5e2f2415c253eec5ddbbd

Contents?: true

Size: 962 Bytes

Versions: 3

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module Bridgetown
  module FrontMatter
    module Loaders
      # An abstract base class for processing front matter
      class Base
        # @param origin_or_layout [Bridgetown::Model::RepoOrigin, Bridgetown::Layout]
        def initialize(origin_or_layout)
          @origin_or_layout = origin_or_layout
        end

        # Reads the contents of a file, returning a possible {Result}
        #
        # @param file_contents [String] the contents of the file being processed
        # @param file_path [String] the path to the file being processed
        # @return [Result, nil]
        def read(file_contents, file_path:) # rubocop:disable Lint/UnusedMethodArgument
          raise "Implement #read in a subclass of Bridgetown::FrontMatter::Loaders::Base"
        end

        private

        # @return [Bridgetown::Model::RepoOrigin, Bridgetown::Layout]
        attr_reader :origin_or_layout
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta3 lib/bridgetown-core/front_matter/loaders/base.rb
bridgetown-core-2.0.0.beta2 lib/bridgetown-core/front_matter/loaders/base.rb
bridgetown-core-2.0.0.beta1 lib/bridgetown-core/front_matter/loaders/base.rb