Sha256: dd0acef3940906720dcb492cd688c3bd4cdab549e894fbc6d936ba622548f0e1

Contents?: true

Size: 650 Bytes

Versions: 10

Compression:

Stored size: 650 Bytes

Contents

module ActiveFedora::Aggregation
  ##
  # Decorates the results of a repository with the given decorator.
  class DecoratingRepository < SimpleDelegator
    attr_reader :decorator
    # @param [#new] decorator A decorator.
    # @param [#find, #new] base_repository A repository to decorate.
    def initialize(decorator, base_repository)
      @decorator = decorator
      super(base_repository)
    end

    def find(id)
      decorate(super(id))
    end

    def new(*args)
      result = decorate(super(*args))
      yield result if block_given?
      result
    end

    private

    def decorate(obj)
      decorator.new(obj)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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