Module: BridgeCache::Data::BridgeModel
- Included in:
- AffiliatedSubAccount, CourseTemplate, CustomField, BridgeCache::Domain, Enrollment, Grant, Group, GroupEnrollment, LearnerCustomFieldValue, LiveCourse, LiveCourseEnrollment, LiveCourseSession, LiveCourseSessionRegistration, Membership, Program, ProgramEnrollment, ProgramGroupEnrollment, ProgramItem, Tag, Tagging, User
- Defined in:
- app/lib/bridge_cache/data/bridge_model.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup(row_ids) ⇒ Object
- #create_from_csv_row(row) ⇒ Object
- #for_domain(domain_id) ⇒ Object
- #import_from_csv(file_path) ⇒ Object
- #webhook_completed(message) ⇒ Object
- #webhook_created(message) ⇒ Object
- #webhook_deleted(message) ⇒ Object
- #webhook_updated(message) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
4 5 6 7 8 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 4 def self.extended(base) base.class_eval do scope :in_domain, -> (domain_id) {for_domain(domain_id)} end end |
Instance Method Details
#cleanup(row_ids) ⇒ Object
18 19 20 21 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 18 def cleanup(row_ids) # Implement this method in your model if you want to do any sort of post creation cleanup. # See tagging.rb for an example. end |
#create_from_csv_row(row) ⇒ Object
14 15 16 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 14 def create_from_csv_row(row) BridgeCache::Plugins::CSVDump::dump_row(self, row) end |
#for_domain(domain_id) ⇒ Object
39 40 41 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 39 def for_domain(domain_id) where(domain_id: domain_id) end |
#import_from_csv(file_path) ⇒ Object
10 11 12 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 10 def import_from_csv(file_path) BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path) end |
#webhook_completed(message) ⇒ Object
35 36 37 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 35 def webhook_completed() raise "Method not implemented" end |
#webhook_created(message) ⇒ Object
27 28 29 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 27 def webhook_created() create_or_update_from_webhook() end |
#webhook_deleted(message) ⇒ Object
31 32 33 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 31 def webhook_deleted() .payload_class.where(bridge_id: .resource_object['id']).destroy_all end |
#webhook_updated(message) ⇒ Object
23 24 25 |
# File 'app/lib/bridge_cache/data/bridge_model.rb', line 23 def webhook_updated() create_or_update_from_webhook() end |