Module: ActiveRecord::Bitemporal::Persistence::PersistenceOptionable

Includes:
Optionable
Included in:
ActiveRecord::Bitemporal::Persistence
Defined in:
lib/activerecord-bitemporal/bitemporal.rb

Instance Method Summary collapse

Methods included from Optionable

#bitemporal_option, #bitemporal_option_merge!, #with_bitemporal_option

Instance Method Details

#bitemporal_at(datetime, &block) ⇒ Object



227
228
229
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 227

def bitemporal_at(datetime, &block)
  transaction_at(datetime) { valid_at(datetime, &block) }
end

#bitemporal_option_merge_with_association!(other) ⇒ Object



231
232
233
234
235
236
237
238
239
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 231

def bitemporal_option_merge_with_association!(other)
  bitemporal_option_merge!(other)

  # Only cached associations will be walked for performance issues
  each_association(deep: true, only_cached: true).each do |association|
    next unless association.respond_to?(:bitemporal_option_merge!)
    association.bitemporal_option_merge!(other)
  end
end

#force_update(&block) ⇒ Object



211
212
213
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 211

def force_update(&block)
  with_bitemporal_option(force_update: true, &block)
end

#force_update?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 215

def force_update?
  bitemporal_option[:force_update].present?
end

#transaction_at(datetime, &block) ⇒ Object



223
224
225
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 223

def transaction_at(datetime, &block)
  with_bitemporal_option(transaction_datetime: datetime, &block)
end

#transaction_datetimeObject



249
250
251
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 249

def transaction_datetime
  bitemporal_option[:transaction_datetime]&.in_time_zone
end

#valid_at(datetime, &block) ⇒ Object



219
220
221
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 219

def valid_at(datetime, &block)
  with_bitemporal_option(valid_datetime: datetime, &block)
end

#valid_dateObject



245
246
247
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 245

def valid_date
  valid_datetime&.to_date
end

#valid_datetimeObject



241
242
243
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 241

def valid_datetime
  bitemporal_option[:valid_datetime]&.in_time_zone
end