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
- #accepts_not_modified? ⇒ Boolean
- #any_remote_changes? ⇒ Boolean
- #expired! ⇒ Object
- #expired? ⇒ Boolean
- #fetch_value ⇒ Object
- #nosync? ⇒ Boolean
- #pull_remote_data! ⇒ Object
- #remote_resource ⇒ Object
Methods included from Nosync
Instance Method Details
#accepts_not_modified? ⇒ Boolean
470 471 472 |
# File 'lib/remotable/active_record_extender.rb', line 470 def accepts_not_modified? respond_to?(:remote_updated_at) end |
#any_remote_changes? ⇒ Boolean
490 491 492 |
# File 'lib/remotable/active_record_extender.rb', line 490 def any_remote_changes? (changed.map(&:to_sym) & local_attribute_names).any? end |
#expired! ⇒ Object
464 465 466 |
# File 'lib/remotable/active_record_extender.rb', line 464 def expired! update_attribute(:expires_at, 1.day.ago) end |
#expired? ⇒ Boolean
460 461 462 |
# File 'lib/remotable/active_record_extender.rb', line 460 def expired? expires_at.nil? || expires_at < Time.now end |
#fetch_value ⇒ Object
496 497 498 499 500 501 502 |
# File 'lib/remotable/active_record_extender.rb', line 496 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
476 477 478 479 480 481 482 |
# File 'lib/remotable/active_record_extender.rb', line 476 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
486 487 488 |
# File 'lib/remotable/active_record_extender.rb', line 486 def remote_resource @remote_resource ||= fetch_remote_resource end |