Sha256: a72e3c784b780a30020cbbaf8ddf2c310666a76494e0435ff9287f296aacaba5

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/WorkPackage
      module WorkPackage
        include Helpers::DateHelper
        # Alias workPackageHasProcedure with fallback.
        # NB: Currently, work packages only have one procedure
        #
        # @return [Grom::Node, nil] a Procedure Grom::Node of the Grom::Node or nil.
        def procedure
          respond_to?(:workPackageHasProcedure) ? workPackageHasProcedure.first : nil
        end

        # Alias workPackageHasWorkPackageableThing with fallback.
        # NB: Currently, work packages only have one work packageable thing
        #
        # @return [Grom::Node, nil] a Procedure Grom::Node of the Grom::Node or nil.
        def work_packageable_thing
          respond_to?(:workPackageHasWorkPackageableThing) ? workPackageHasWorkPackageableThing.first : nil
        end

        # @return [String, nil] the name of the Grom::Node or an empty string.
        def work_packageable_thing_name
          work_packageable_thing&.name
        end

        # Alias workPackageHasBusinessItem with fallback.
        #
        # @return [Array, Array] an array of BusinessItem Grom::Nodes or an empty array.
        def business_items
          respond_to?(:workPackageHasBusinessItem) ? workPackageHasBusinessItem : []
        end

        # Alias oldestBusinessItemDate with fallback.
        #
        # @return [Date, nil] a date or nil.
        def oldest_business_item_date
          respond_to?(:oldestBusinessItemDate) ? DateTime.parse(oldestBusinessItemDate) : nil
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.27.6 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.27.5 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/work_package.rb