Sha256: ec6324b2445f866e5d6d977effb304889598637c0f218c0585ba9ef8ac1cf3d3

Contents?: true

Size: 728 Bytes

Versions: 5

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Util
    module Lazy
      class Value
        attr_reader :access_keys

        def initialize(value, access_keys = [])
          @value = value
          @access_keys = access_keys
        end

        def evaluate_from(configuration)
          matching_lazy_value = configuration.fetch(@access_keys)
          matching_lazy_value.evaluate
        end

        def evaluate
          @value
        end

        def lazy?
          true
        end

        def reached_by(parent_access_keys, access_key)
          @access_keys = parent_access_keys + [access_key]
          self
        end

        def to_s
          evaluate.to_s
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-2.2.0 lib/grape/util/lazy/value.rb
grape-2.1.3 lib/grape/util/lazy/value.rb
grape-2.1.2 lib/grape/util/lazy/value.rb
grape-2.1.1 lib/grape/util/lazy/value.rb
grape-2.1.0 lib/grape/util/lazy/value.rb