Class: Tataru::Instructions::ReadInstruction

Inherits:
ResourceInstruction show all
Defined in:
lib/tataru/instructions/read_instruction.rb

Overview

read properties of resource

Instance Attribute Summary

Attributes inherited from Tataru::Instruction

#memory

Instance Method Summary collapse

Methods inherited from ResourceInstruction

#desc

Methods inherited from Tataru::Instruction

#execute, expects

Instance Method Details

#fieldsObject



23
24
25
# File 'lib/tataru/instructions/read_instruction.rb', line 23

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

#resourceObject



19
20
21
# File 'lib/tataru/instructions/read_instruction.rb', line 19

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

#resource_classObject



15
16
17
# File 'lib/tataru/instructions/read_instruction.rb', line 15

def resource_class
  desc.resource_class
end

#runObject



7
8
9
10
11
12
13
# File 'lib/tataru/instructions/read_instruction.rb', line 7

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