Class: PostgresUpsert::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/postgres_upsert/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(insert_result, update_result, copy_result) ⇒ Result

Returns a new instance of Result.



5
6
7
8
9
# File 'lib/postgres_upsert/result.rb', line 5

def initialize(insert_result, update_result, copy_result)
  @inserted = insert_result ? insert_result.cmd_tuples : 0
  @updated = update_result ? update_result.cmd_tuples : 0  
  @copied = copy_result ? copy_result.cmd_tuples : 0  
end

Instance Attribute Details

#insertedObject (readonly)

Returns the value of attribute inserted.



3
4
5
# File 'lib/postgres_upsert/result.rb', line 3

def inserted
  @inserted
end

#updatedObject (readonly)

Returns the value of attribute updated.



3
4
5
# File 'lib/postgres_upsert/result.rb', line 3

def updated
  @updated
end

Instance Method Details

#changed_rowsObject



11
12
13
# File 'lib/postgres_upsert/result.rb', line 11

def changed_rows
  @inserted + @updated
end

#copied_rowsObject



15
16
17
# File 'lib/postgres_upsert/result.rb', line 15

def copied_rows
  @copied
end

#updated_rowsObject



19
20
21
# File 'lib/postgres_upsert/result.rb', line 19

def updated_rows
  @updated
end