Class: Hecks::Adapters::SQLDatabase::Commands::Read

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/read.rb,
lib/commands/read/fetch_references.rb

Defined Under Namespace

Classes: FetchReferences

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, head:, entity_class:) ⇒ Read

Returns a new instance of Read.



9
10
11
12
13
14
# File 'lib/commands/read.rb', line 9

def initialize(id:, head:, entity_class:)
  @head = head
  @table = Table.factory([@head]).first
  @id = id
  @entity_class = entity_class
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



7
8
9
# File 'lib/commands/read.rb', line 7

def entity
  @entity
end

#headObject (readonly)

Returns the value of attribute head.



7
8
9
# File 'lib/commands/read.rb', line 7

def head
  @head
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/commands/read.rb', line 7

def id
  @id
end

#tableObject (readonly)

Returns the value of attribute table.



7
8
9
# File 'lib/commands/read.rb', line 7

def table
  @table
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
# File 'lib/commands/read.rb', line 16

def call
  fetch_entity
  return if @entity.nil?
  @entity_class.new(
    @entity.merge(FetchReferences.new(self).call.reference_map)
  )
end