Sha256: 57e9f03a004f99f3a21d77f993ec8d433295dbada013109cc4f90d44b7098f73

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

require_relative './entry'

class ActiveSet
  class Instructions
    attr_reader :hash

    def initialize(hash)
      @hash = hash
      @flattened_hash = hash.flatten_keys
    end

    def process_adapter(set:, adapter:)
      @flattened_hash.reject { |_, v| v.blank? }
                     .reduce(set) do |inner_set, (keypath, value)|
                       instruction = Entry.new(keypath, value)
                       adapter.new(instruction).process(inner_set)
                     end
    end

    def get(keypath)
      @hash.dig(*keypath)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeset-0.3.1 lib/active_set/instructions/base.rb