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



271
272
273
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 271

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

#bitemporal_option_merge_with_association!(other) ⇒ Object



275
276
277
278
279
280
281
282
283
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 275

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



255
256
257
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 255

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

#force_update?Boolean

Returns:

  • (Boolean)


259
260
261
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 259

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

#transaction_at(datetime, &block) ⇒ Object



267
268
269
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 267

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

#transaction_datetimeObject



293
294
295
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 293

def transaction_datetime
  bitemporal_option[:transaction_datetime]&.in_time_zone
end

#valid_at(datetime, &block) ⇒ Object



263
264
265
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 263

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

#valid_dateObject



289
290
291
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 289

def valid_date
  valid_datetime&.to_date
end

#valid_datetimeObject



285
286
287
# File 'lib/activerecord-bitemporal/bitemporal.rb', line 285

def valid_datetime
  bitemporal_option[:valid_datetime]&.in_time_zone
end