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
78
79
80
|
# File 'lib/activerecord-bitemporal.rb', line 78
def bitemporal_id_key
self.class.bitemporal_id_key
end
|
#bitemporal_ignore_update_columns ⇒ Object
82
83
84
|
# File 'lib/activerecord-bitemporal.rb', line 82
def bitemporal_ignore_update_columns
[]
end
|
#id_in_database ⇒ Object
86
87
88
|
# File 'lib/activerecord-bitemporal.rb', line 86
def id_in_database
swapped_id.presence || super
end
|
#previously_force_updated? ⇒ Boolean
90
91
92
|
# File 'lib/activerecord-bitemporal.rb', line 90
def previously_force_updated?
@previously_force_updated
end
|
#swap_id!(without_clear_changes_information: false) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/activerecord-bitemporal.rb', line 63
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
70
71
72
|
# File 'lib/activerecord-bitemporal.rb', line 70
def swapped_id
@_swapped_id || self.id
end
|
#swapped_id_previously_was ⇒ Object
74
75
76
|
# File 'lib/activerecord-bitemporal.rb', line 74
def swapped_id_previously_was
@_swapped_id_previously_was
end
|
#transaction_from_cannot_be_greater_equal_than_transaction_to ⇒ Object
100
101
102
103
104
|
# File 'lib/activerecord-bitemporal.rb', line 100
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
94
95
96
97
98
|
# File 'lib/activerecord-bitemporal.rb', line 94
def valid_from_cannot_be_greater_equal_than_valid_to
if self[valid_from_key] && self[valid_to_key] && self[valid_from_key] >= self[valid_to_key]
errors.add(valid_from_key, "can't be greater equal than #{valid_to_key}")
end
end
|