Sha256: 5ba8e4eab0adf29af1a1f0f4e2c5f1074dbc8207d3c244f14273252dcebd800f
Contents?: true
Size: 967 Bytes
Versions: 2
Compression:
Stored size: 967 Bytes
Contents
module Troo class BoardPersistence class << self def for(resource, options = {}) new(resource, options).persist end end def initialize(resource, options = {}) @resource = resource @options = options end def persist return local if local_identical? return updated if local_exists? return created end private attr_reader :resource, :options def created Troo::Board.create(remote) end def updated local.update(remote) && local end def local_identical? return false unless local_exists? return false if local_data != remote true end def local_data local.external_attributes end def local_exists? !!local end def local @local ||= Troo::Board.first(external_board_id: resource.id) end def remote @remote ||= Troo::External::BoardAdaptor.adapt(resource) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
troo-0.0.3 | lib/troo/models/board_persistence.rb |
troo-0.0.2 | lib/troo/models/board_persistence.rb |