Sha256: bd099be2b2bc093354186f51dd7790342e68d0a8834cb2cbf3fc1a4cf0635967

Contents?: true

Size: 1.79 KB

Versions: 8

Compression:

Stored size: 1.79 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 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 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

        # @return [Grom::Node, nil] a Laying Grom::Node or nil.
        def laying
          respond_to?(:workPackageHasProcedure) ? workPackageHasProcedure.first : nil
        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

8 entries across 8 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.32.1 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.32.0 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.31.1 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.31.0 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.31.0.pre.rc lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.30.0 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.29.0 lib/parliament/grom/decorator/work_package.rb
parliament-grom-decorators-0.27.7 lib/parliament/grom/decorator/work_package.rb