Sha256: 55b54aec50f82c17c7e7200128cce3f53c3bd7c6ab3c41521c1d703aa392f8b9

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

module Tataru
  # resolver for data
  class Resolver
    def initialize(expression)
      @expression = expression
    end

    def representation
      @representation ||= generate_representation
    end

    def dependencies
      representation.dependencies
    end

    private

    def generate_representation
      case @expression
      when String
        Representations::LiteralRepresentation.new(@expression)
      when Numeric
        Representations::LiteralRepresentation.new(@expression)
      when Array
        Representations::ArrayRepresentation.new(@expression)
      when Hash
        Representations::HashRepresentation.new(@expression)
      when Representations::ResourceRepresentation
        @expression
      when Representations::OutputRepresentation
        @expression
      else
        raise "invalid value: #{@expression.inspect}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 lib/tataru/resolver.rb