Module: BridgeCache

Defined in:
lib/bridge_cache.rb,
lib/bridge_cache/engine.rb,
lib/bridge_cache/version.rb,
app/models/bridge_cache/tag.rb,
app/models/bridge_cache/user.rb,
app/models/bridge_cache/grant.rb,
app/models/bridge_cache/group.rb,
app/models/bridge_cache/domain.rb,
app/models/bridge_cache/program.rb,
app/models/bridge_cache/tagging.rb,
app/models/bridge_cache/enrollment.rb,
app/models/bridge_cache/membership.rb,
app/models/bridge_cache/live_course.rb,
app/models/bridge_cache/custom_field.rb,
app/models/bridge_cache/program_item.rb,
app/models/bridge_cache/course_template.rb,
app/models/bridge_cache/group_enrollment.rb,
app/models/bridge_cache/bridge_base_model.rb,
app/models/bridge_cache/application_record.rb,
app/models/bridge_cache/enrollment_profile.rb,
app/models/bridge_cache/program_enrollment.rb,
app/helpers/bridge_cache/application_helper.rb,
app/models/bridge_cache/live_course_session.rb,
app/models/bridge_cache/affiliated_sub_account.rb,
app/models/bridge_cache/live_course_enrollment.rb,
app/models/bridge_cache/program_group_enrollment.rb,
app/models/bridge_cache/learner_custom_field_value.rb,
app/controllers/bridge_cache/application_controller.rb,
app/models/bridge_cache/live_course_session_registration.rb

Defined Under Namespace

Modules: ApplicationHelper, Data, Jobs, Plugins, Utils, Webhooks Classes: AffiliatedSubAccount, ApplicationController, ApplicationRecord, BridgeBaseModel, CourseTemplate, CustomField, Domain, Engine, Enrollment, EnrollmentProfile, Grant, Group, GroupEnrollment, LearnerCustomFieldValue, LiveCourse, LiveCourseEnrollment, LiveCourseSession, LiveCourseSessionRegistration, Membership, Program, ProgramEnrollment, ProgramGroupEnrollment, ProgramItem, Tag, Tagging, User

Constant Summary collapse

WRITER_METHODS =
%w[use_internal_database batch_size is_subaccount].freeze
READ_METHODS =
%w[models].freeze
READ_WRITE_METHODS =
%w[].freeze
DEFAULT_BATCH_SIZE =
10_000
DEFAULT_MODELS =
%(domain affiliated_sub_account).freeze
VERSION =
'0.3.01'.freeze

Class Method Summary collapse

Class Method Details

.batch_sizeObject



29
30
31
# File 'lib/bridge_cache.rb', line 29

def batch_size
  @batch_size || DEFAULT_BATCH_SIZE
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (BridgeCache)

    the object that the method was called on



19
20
21
# File 'lib/bridge_cache.rb', line 19

def configure
  yield self if block_given?
end

.modelsObject



37
38
39
40
41
# File 'lib/bridge_cache.rb', line 37

def models
  return @models if defined?(@models)

  @models = merged_required_models([])
end

.models=(models) ⇒ Object



33
34
35
# File 'lib/bridge_cache.rb', line 33

def models=(models)
  @models = merged_required_models(models)
end

.primary_keyObject



43
44
45
# File 'lib/bridge_cache.rb', line 43

def primary_key
  @use_internal_database ? :bridge_id : :id
end

.resolved_models(remove_root_models) ⇒ Object



47
48
49
50
# File 'lib/bridge_cache.rb', line 47

def resolved_models(remove_root_models)
  return @models unless remove_root_models
  @models.reject { |model| DEFAULT_MODELS.include?(model) }
end

.use_internal_databaseObject



23
24
25
26
27
# File 'lib/bridge_cache.rb', line 23

def use_internal_database
  return @use_internal_database if defined?(@use_internal_database)

  @use_internal_database = true
end