Sha256: 618e34b9b0ca673acfae1716a58f7d2a7cd3184f2d6cbe00ef39fee01c22996b

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module Tataru
  module Instructions
    # read properties of resource
    class ReadInstruction < ResourceInstruction
      def run
        results = resource.read(fields)
        memory.hash[:temp][resource_name] = {}
        fields.each do |k|
          memory.hash[:temp][resource_name][k] = results[k]
        end
      end

      def resource_class
        desc.resource_class
      end

      def resource
        resource_class.new(memory.hash[:remote_ids][resource_name])
      end

      def fields
        @fields ||= desc.immutable_fields + desc.mutable_fields
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 lib/tataru/instructions/read_instruction.rb