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=

Instance Method Details

#any_remote_changes?Boolean

Returns:

  • (Boolean)


343
344
345
# File 'lib/remotable/active_record_extender.rb', line 343

def any_remote_changes?
  (changed.map(&:to_sym) & local_attribute_names).any?
end

#expired!Object



323
324
325
# File 'lib/remotable/active_record_extender.rb', line 323

def expired!
  update_attribute(:expires_at, 1.day.ago)
end

#expired?Boolean

Returns:

  • (Boolean)


319
320
321
# File 'lib/remotable/active_record_extender.rb', line 319

def expired?
  expires_at.nil? || expires_at < Time.now
end

#nosync?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/remotable/active_record_extender.rb', line 11

def nosync?
  self.class.nosync? || super
end

#pull_remote_data!Object



329
330
331
332
333
334
335
# File 'lib/remotable/active_record_extender.rb', line 329

def pull_remote_data!
  if remote_resource
    merge_remote_data!(remote_resource)
  elsif fetch_value
    remote_model_has_been_destroyed!
  end
end

#remote_resourceObject



339
340
341
# File 'lib/remotable/active_record_extender.rb', line 339

def remote_resource
  @remote_resource ||= fetch_remote_resource
end