Sha256: 82914901835bbf1750178e77da02498960f2e100464aed0c199f029d7ab203fc

Contents?: true

Size: 657 Bytes

Versions: 10

Compression:

Stored size: 657 Bytes

Contents

module ActiveFedora::Aggregation
  ##
  # Decorates a proxy owner such that it knows how to delete a proxy from its
  # ordered list.
  class ProxyOwner < SimpleDelegator
    def is_a?(klass)
      __getobj__.is_a?(klass)
    end

    # @param [#next, #prev] proxy A Proxy link to delete.
    def delete_proxy!(proxy)
      if proxy == head || head.nil? # Head is nil if proxy is now deleted.
        self.head = proxy.next
      end
      if proxy == tail || tail.nil? # Head is nil if proxy is now deleted.
        self.tail = proxy.prev
      end
      [head, tail].uniq.compact.each(&:reload)
      if changed?
        save!
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activefedora-aggregation-0.9.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.8.1 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.8.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.7.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.6.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.5.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.4.2 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.4.1 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.4.0 lib/active_fedora/aggregation/proxy_owner.rb
activefedora-aggregation-0.3.0 lib/active_fedora/aggregation/proxy_owner.rb