Sha256: 77fc2211cb73c4f740a6d0cc0893e67c52fc28c3dbd52faea5b4518c66351aff

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module SnapshotInspector
  class Snapshot
    class Context
      class_attribute :registry, default: {}, instance_writer: false, instance_predicate: false

      def self.test_framework(name)
        registry[name] = self
      end

      def self.extract(context)
        record = registry[context[:test_framework]].new
        record.extract(context)
        record
      end

      def self.from_hash(hash)
        record = registry[hash[:test_framework].to_sym].new
        record.from_hash(hash)
        record
      end

      # @private
      def extract(_context)
        raise "Implement in a child class."
      end

      # @private
      def from_hash(_hash)
        raise "Implement in a child class."
      end

      def to_slug
        raise "Implement in a child class."
      end

      def name
        raise "Implement in a child class."
      end

      def test_group
        raise "Implement in a child class."
      end

      def order_index
        raise "Implement in a child class."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snapshot_inspector-0.1.1 app/models/snapshot_inspector/snapshot/context.rb