Module: ActiveRecord::Bitemporal::Bitemporalize::InstanceMethods
- Includes:
- Persistence
- Defined in:
- lib/activerecord-bitemporal.rb
Instance Method Summary
collapse
#_create_record, #_find_record, #_update_row, #destroy, #save, #save!
#bitemporal_at, #bitemporal_option_merge_with_association!, #force_update, #force_update?, #transaction_at, #transaction_datetime, #valid_at, #valid_date, #valid_datetime
Methods included from Optionable
#bitemporal_option, #bitemporal_option_merge!, #with_bitemporal_option
Instance Method Details
#bitemporal_id_key ⇒ Object
95
96
97
|
# File 'lib/activerecord-bitemporal.rb', line 95
def bitemporal_id_key
self.class.bitemporal_id_key
end
|
#bitemporal_ignore_update_columns ⇒ Object
99
100
101
|
# File 'lib/activerecord-bitemporal.rb', line 99
def bitemporal_ignore_update_columns
[]
end
|
#id_in_database ⇒ Object
103
104
105
|
# File 'lib/activerecord-bitemporal.rb', line 103
def id_in_database
swapped_id.presence || super
end
|
#previously_force_updated? ⇒ Boolean
107
108
109
|
# File 'lib/activerecord-bitemporal.rb', line 107
def previously_force_updated?
@previously_force_updated
end
|
#swap_id!(without_clear_changes_information: false) ⇒ Object
80
81
82
83
84
85
|
# File 'lib/activerecord-bitemporal.rb', line 80
def swap_id!(without_clear_changes_information: false)
@_swapped_id_previously_was = nil
@_swapped_id = self.id
self.id = self.send(bitemporal_id_key)
clear_attribute_changes([:id]) unless without_clear_changes_information
end
|
#swapped_id ⇒ Object
87
88
89
|
# File 'lib/activerecord-bitemporal.rb', line 87
def swapped_id
@_swapped_id || self.id
end
|
#swapped_id_previously_was ⇒ Object
91
92
93
|
# File 'lib/activerecord-bitemporal.rb', line 91
def swapped_id_previously_was
@_swapped_id_previously_was
end
|
#transaction_from_cannot_be_greater_equal_than_transaction_to ⇒ Object
117
118
119
120
121
|
# File 'lib/activerecord-bitemporal.rb', line 117
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
111
112
113
114
115
|
# File 'lib/activerecord-bitemporal.rb', line 111
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
|