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



239
240
241
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 239

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

#bitemporal_option_merge_with_association!(other) ⇒ Object



243
244
245
246
247
248
249
250
251
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 243

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



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

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

#force_update?Boolean

Returns:

  • (Boolean)


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

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

#transaction_at(datetime, &block) ⇒ Object



235
236
237
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 235

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

#transaction_datetimeObject



261
262
263
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 261

def transaction_datetime
  bitemporal_option[:transaction_datetime]&.in_time_zone
end

#valid_at(datetime, &block) ⇒ Object



231
232
233
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 231

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

#valid_dateObject



257
258
259
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 257

def valid_date
  valid_datetime&.to_date
end

#valid_datetimeObject



253
254
255
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 253

def valid_datetime
  bitemporal_option[:valid_datetime]&.in_time_zone
end