Sha256: a27e2784661f4e331e74834e031eaf4ecd423e24ee7939675d6cc47b5047a052

Contents?: true

Size: 946 Bytes

Versions: 29

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  ##
  # A list of child work types a user may choose to attach for a given work type
  #
  # These lists are used when users select among work types to attach to an
  # existing work, e.g. from Actions available on the show view.
  #
  # @example
  #   child_types = Hyrax::ChildTypes.for(parent: MyWorkType)
  #
  class ChildTypes
    include Enumerable
    extend Forwardable

    def_delegators :@types, :each

    ##
    # @!attribute [r] types
    #   @return [Array<Class>]
    attr_reader :types

    ##
    # @params [Class] parent
    # @return [Enumerable<Class>] a list of classes that are valid as child types for `parent`
    def self.for(parent:)
      return new(parent.valid_child_concerns) if
        parent.respond_to?(:valid_child_concerns)

      new([parent])
    end

    ##
    # @param [Array<Class>] types
    def initialize(types)
      @types = types.to_a
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/services/hyrax/child_types.rb
hyrax-5.0.4 app/services/hyrax/child_types.rb
hyrax-5.0.3 app/services/hyrax/child_types.rb
hyrax-5.0.2 app/services/hyrax/child_types.rb
hyrax-5.0.1 app/services/hyrax/child_types.rb
hyrax-5.0.0 app/services/hyrax/child_types.rb
hyrax-5.0.0.rc3 app/services/hyrax/child_types.rb
hyrax-5.0.0.rc2 app/services/hyrax/child_types.rb
hyrax-5.0.0.rc1 app/services/hyrax/child_types.rb
hyrax-3.6.0 app/services/hyrax/child_types.rb
hyrax-4.0.0 app/services/hyrax/child_types.rb
hyrax-4.0.0.rc3 app/services/hyrax/child_types.rb
hyrax-4.0.0.rc2 app/services/hyrax/child_types.rb
hyrax-4.0.0.rc1 app/services/hyrax/child_types.rb
hyrax-3.5.0 app/services/hyrax/child_types.rb
hyrax-4.0.0.beta2 app/services/hyrax/child_types.rb
hyrax-3.4.2 app/services/hyrax/child_types.rb
hyrax-4.0.0.beta1 app/services/hyrax/child_types.rb
hyrax-3.4.1 app/services/hyrax/child_types.rb
hyrax-3.4.0 app/services/hyrax/child_types.rb