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
339 340 341 342 343 344 345 |
# File 'motion-prime/models/_sync_mixin.rb', line 339 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
347 348 349 350 351 352 353 |
# File 'motion-prime/models/_sync_mixin.rb', line 347 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
355 356 357 358 359 360 361 |
# File 'motion-prime/models/_sync_mixin.rb', line 355 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
370 371 372 373 374 |
# File 'motion-prime/models/_sync_mixin.rb', line 370 def updatable_attribute(attribute, = {}, &block) [:block] = block if block_given? self._updatable_attributes ||= {} self._updatable_attributes[attribute] = end |
#updatable_attributes(*attrs) ⇒ Object
363 364 365 366 367 368 |
# File 'motion-prime/models/_sync_mixin.rb', line 363 def updatable_attributes(*attrs) return self._updatable_attributes if attrs.blank? attrs.each do |attribute| updatable_attribute(attribute) end end |