Class: Hecks::Adapters::SQLDatabase::Commands::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/create.rb,
lib/commands/create/add_to_join_tables.rb,
lib/commands/create/find_or_create_references.rb

Defined Under Namespace

Classes: AddToJoinTables, FindOrCreateReferences

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes:, head:) ⇒ Create

Returns a new instance of Create.



11
12
13
14
15
16
17
# File 'lib/commands/create.rb', line 11

def initialize(attributes:, head:)
  @attributes = attributes.clone
  @reference_ids = {}
  @head = head
  @references = @head.references
  @table = Table.factory([@head]).first
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/commands/create.rb', line 9

def id
  @id
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'lib/commands/create.rb', line 19

def call
  DB.transaction do
    find_or_create_references
    create
    add_to_join_tables
  end
  self
end