Class: TokenAuth::SynchronizableResource
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- 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
17 18 19 20 21 22 23 24 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 17 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
11 12 13 14 15 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 11 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
30 31 32 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 30 def klass class_name.constantize end |
#records ⇒ Object
26 27 28 |
# File 'app/models/token_auth/synchronizable_resource.rb', line 26 def records klass.where(entity_id_attribute_name => entity_id) end |