Sha256: 3e3ac5c2b066e275358b965cb7263edaa17afc20778c0c336955694286db8c57

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/WorkPackageableThing
      module WorkPackageableThing
        include Helpers::DateHelper
        # Alias workPackageableThingName with fallback.
        #
        # @return [String, String] the name of the Grom::Node or an empty string.
        def name
          respond_to?(:workPackageableThingName) ? workPackageableThingName : ''
        end

        # Alias workPackageableThingHasWorkPackage with fallback.
        # NB: Currently, a work packageable thing only has one work package
        #
        # @return [Grom::Node, nil] a WorkPackage Grom::Node or nil.
        def work_package
          respond_to?(:workPackageableThingHasWorkPackage) ? workPackageableThingHasWorkPackage.first : nil
        end

        # Alias workPackageableThingHasWorkPackage with fallback.
        #
        # @return [String, String] a web link or an empty string.
        def weblink
          respond_to?(:workPackageableThingHasWorkPackageableThingWebLink) ? workPackageableThingHasWorkPackageableThingWebLink : ''
        end

        # # @return [Date, nil] an array of BusinessItem Grom::Nodes or an empty array.
        # def oldest_business_item_date
        #   work_package&.oldest_business_item_date
        # end

        # Alias workPackageableThingComingIntoForceDate with fallback.
        #
        # @return [DateTime, nil] the expiry date (time limit) of a work package or nil.
        def time_limit_for_objection_date
          respond_to?(:workPackageableThingTimeLimitForObjectionEndDate) ? DateTime.parse(workPackageableThingTimeLimitForObjectionEndDate) : nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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