Sha256: 849249fe8b8f2b6ac9e5ed2bcec61ae8cd00b2914452bd7630e21d2bb61e31cd

Contents?: true

Size: 352 Bytes

Versions: 40

Compression:

Stored size: 352 Bytes

Contents

module Ddr
  module HasChildren
    extend ActiveSupport::Concern

    def children
      Ddr.query_service.find_inverse_references_by(resource: self, property: 'parent_id')
    end

    def first_child
      sorted_children.first
    end

    def sorted_children
      children.sort_by{ |e| [ e.local_id || '', e.ingestion_date ] }
    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ddr-core-1.6.1 app/models/concerns/ddr/has_children.rb
ddr-core-1.6.0 app/models/concerns/ddr/has_children.rb
ddr-core-1.5.5 app/models/concerns/ddr/has_children.rb
ddr-core-1.5.4 app/models/concerns/ddr/has_children.rb
ddr-core-1.5.2 app/models/concerns/ddr/has_children.rb
ddr-core-1.5.3 app/models/concerns/ddr/has_children.rb
ddr-core-1.5.1 app/models/concerns/ddr/has_children.rb
ddr-core-1.4.4 app/models/concerns/ddr/has_children.rb
ddr-core-1.4.3 app/models/concerns/ddr/has_children.rb
ddr-core-1.4.2 app/models/concerns/ddr/has_children.rb
ddr-core-1.4.0 app/models/concerns/ddr/has_children.rb
ddr-core-1.3.0 app/models/concerns/ddr/has_children.rb
ddr-core-1.2.0 app/models/concerns/ddr/has_children.rb
ddr-core-1.2.0.rc3 app/models/concerns/ddr/has_children.rb
ddr-core-1.2.0.rc2 app/models/concerns/ddr/has_children.rb
ddr-core-1.2.0.rc1 app/models/concerns/ddr/has_children.rb
ddr-core-1.1.2 app/models/concerns/ddr/has_children.rb
ddr-core-1.1.1 app/models/concerns/ddr/has_children.rb
ddr-core-1.1.0 app/models/concerns/ddr/has_children.rb
ddr-core-1.0.0 app/models/concerns/ddr/has_children.rb