Class: TokenAuth::SynchronizableResource
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- TokenAuth::SynchronizableResource
- Includes:
- UuidEnabled
- Defined in:
- app/models/token_auth/synchronizable_resource.rb
Overview
A resource that may be pushed and/or pulled by an entity.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.apply_filter(relation, filter) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 18 def self.apply_filter(relation, filter) return relation unless filter && filter[:updated_at] && filter[:updated_at][:gt] = filter[:updated_at][:gt] relation.where(relation.arel_table[:updated_at].gt()) end |
.pullable_records_for(entity_id:, filter:) ⇒ Object
12 13 14 15 16 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 12 def self.pullable_records_for(entity_id:, filter:) where(is_pullable: true, entity_id: entity_id) .map { |r| apply_filter(r.records, filter) } .flatten end |
Instance Method Details
#klass ⇒ Object
31 32 33 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 31 def klass class_name.constantize end |
#records ⇒ Object
27 28 29 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 27 def records klass.where(entity_id_attribute_name => entity_id) end |