Sha256: 05a59720c5c5e0886eb4f2953b1e88697343252774aa5d45f4d7c9d74d91dd28

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module Krikri
  ##
  # A behavior that provides methods for working with aggregations
  # (as defined by DPLA::MAP::Aggregation), in the context of entities that
  # are generated by activities.
  #
  # @see Krikri::EntityBehavior
  #
  class AggregationEntityBehavior < Krikri::EntityBehavior

    ##
    # @param load [Boolean]  Whether to load the whole record from the LDP
    #   server.  DPLA::MAP::Aggregation#get is slow, because it results in a
    #   network request, so this provides the possibility of avoiding it.
    #   Default: true.
    #
    # @param include_invalidated [Boolean] Whether to include entities that
    #   have been invalidated with prov:invalidatedAtTime.  Default: false
    #
    # @see Krikri::EntityBehavior::entities
    # @return [Enumerator] DPLA::MAP::Aggregation objects
    #
    def entities(load = true, include_invalidated = false)
      @activity.entity_uris(include_invalidated).lazy.map do |uri|
        agg = DPLA::MAP::Aggregation.new(uri)
        agg.get if load
        agg
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
krikri-0.12.0 lib/krikri/entity_behaviors/aggregation_entity_behavior.rb
krikri-0.12.0.pre.rc.1 lib/krikri/entity_behaviors/aggregation_entity_behavior.rb