Module: Remotable::ActiveRecordExtender
- Extended by:
- ActiveSupport::Concern
- Includes:
- Nosync
- Defined in:
- lib/remotable/active_record_extender.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary
collapse
Methods included from Nosync
#nosync, #nosync!, #nosync=, #nosync_value?
Instance Method Details
#accepts_not_modified? ⇒ Boolean
423
424
425
|
# File 'lib/remotable/active_record_extender.rb', line 423
def accepts_not_modified?
respond_to?(:updated_at)
end
|
#any_remote_changes? ⇒ Boolean
443
444
445
|
# File 'lib/remotable/active_record_extender.rb', line 443
def any_remote_changes?
(changed.map(&:to_sym) & local_attribute_names).any?
end
|
#expired! ⇒ Object
417
418
419
|
# File 'lib/remotable/active_record_extender.rb', line 417
def expired!
update_attribute(:expires_at, 1.day.ago)
end
|
#expired? ⇒ Boolean
413
414
415
|
# File 'lib/remotable/active_record_extender.rb', line 413
def expired?
expires_at.nil? || expires_at < Time.now
end
|
#fetch_value ⇒ Object
449
450
451
452
453
454
455
|
# File 'lib/remotable/active_record_extender.rb', line 449
def fetch_value
if local_key.is_a?(Array)
local_key.map(&method(:send))
else
send(local_key)
end
end
|
#nosync? ⇒ Boolean
12
13
14
15
|
# File 'lib/remotable/active_record_extender.rb', line 12
def nosync?
return super if nosync_value?
self.class.nosync?
end
|
#pull_remote_data! ⇒ Object
429
430
431
432
433
434
435
|
# File 'lib/remotable/active_record_extender.rb', line 429
def pull_remote_data!
if remote_resource
merge_remote_data!(remote_resource)
elsif fetch_value
remote_model_has_been_destroyed!
end
end
|
#remote_resource ⇒ Object
439
440
441
|
# File 'lib/remotable/active_record_extender.rb', line 439
def remote_resource
@remote_resource ||= fetch_remote_resource
end
|