Module: ActiveRecord::Bitemporal::Bitemporalize::InstanceMethods
- Includes:
- Persistence
- Defined in:
- lib/activerecord-bitemporal.rb
Instance Method Summary
collapse
#_create_record, #_update_row, #destroy, #save, #save!
#bitemporal_option_merge_with_association!, #force_update, #force_update?, #transaction_at, #transaction_datetime, #valid_at, #valid_datetime
Methods included from Optionable
#bitemporal_option, #bitemporal_option_merge!, #with_bitemporal_option
Instance Method Details
#bitemporal_id_key ⇒ Object
88
89
90
|
# File 'lib/activerecord-bitemporal.rb', line 88
def bitemporal_id_key
self.class.bitemporal_id_key
end
|
#bitemporal_ignore_update_columns ⇒ Object
92
93
94
|
# File 'lib/activerecord-bitemporal.rb', line 92
def bitemporal_ignore_update_columns
[]
end
|
#id_in_database ⇒ Object
96
97
98
|
# File 'lib/activerecord-bitemporal.rb', line 96
def id_in_database
swapped_id.presence || super
end
|
#swap_id!(without_clear_changes_information: false) ⇒ Object
78
79
80
81
82
|
# File 'lib/activerecord-bitemporal.rb', line 78
def swap_id!(without_clear_changes_information: false)
@_swapped_id = self.id
self.id = self.send(bitemporal_id_key)
clear_attribute_changes([:id]) unless without_clear_changes_information
end
|
#swapped_id ⇒ Object
84
85
86
|
# File 'lib/activerecord-bitemporal.rb', line 84
def swapped_id
@_swapped_id || self.id
end
|
#transaction_from_cannot_be_greater_equal_than_transaction_to ⇒ Object
106
107
108
109
110
|
# File 'lib/activerecord-bitemporal.rb', line 106
def transaction_from_cannot_be_greater_equal_than_transaction_to
if transaction_from && transaction_to && transaction_from >= transaction_to
errors.add(:transaction_from, "can't be greater equal than transaction_to")
end
end
|
#valid_from_cannot_be_greater_equal_than_valid_to ⇒ Object
100
101
102
103
104
|
# File 'lib/activerecord-bitemporal.rb', line 100
def valid_from_cannot_be_greater_equal_than_valid_to
if valid_from && valid_to && valid_from >= valid_to
errors.add(:valid_from, "can't be greater equal than valid_to")
end
end
|