Module: MotionPrime::ModelSyncMixin::ClassMethods
- Defined in:
- motion-prime/models/_sync_mixin.rb
Instance Method Summary collapse
- #fetch_all_with_attributes(data) ⇒ Object
- #new(data = {}, options = {}) ⇒ Object
- #sync_url(url = nil, &block) ⇒ Object
- #updatable_attribute(attribute, options = {}, &block) ⇒ Object
- #updatable_attributes(*attrs) ⇒ Object
Instance Method Details
#fetch_all_with_attributes(data) ⇒ Object
342 343 344 345 346 347 348 |
# File 'motion-prime/models/_sync_mixin.rb', line 342 def fetch_all_with_attributes(data) data.map do |attrs| item = self.new item.fetch_with_attributes(attrs) item end end |
#new(data = {}, options = {}) ⇒ Object
350 351 352 353 354 355 356 |
# File 'motion-prime/models/_sync_mixin.rb', line 350 def new(data = {}, = {}) model = super if fetch_attributes = [:fetch_attributes] model.fetch_with_attributes(fetch_attributes) end model end |
#sync_url(url = nil, &block) ⇒ Object
358 359 360 361 362 363 364 |
# File 'motion-prime/models/_sync_mixin.rb', line 358 def sync_url(url = nil, &block) if url || block_given? self._sync_url = url || block else self._sync_url end end |
#updatable_attribute(attribute, options = {}, &block) ⇒ Object
373 374 375 376 377 |
# File 'motion-prime/models/_sync_mixin.rb', line 373 def updatable_attribute(attribute, = {}, &block) [:block] = block if block_given? self._updatable_attributes ||= {} self._updatable_attributes[attribute] = end |
#updatable_attributes(*attrs) ⇒ Object
366 367 368 369 370 371 |
# File 'motion-prime/models/_sync_mixin.rb', line 366 def updatable_attributes(*attrs) return self._updatable_attributes if attrs.blank? attrs.each do |attribute| updatable_attribute(attribute) end end |