Sha256: 59cec8dc9d99693db6e69b37a6b736b63e543160fc09f5c9220fcb5afc97e70a

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/BusinessItem
      module BusinessItem
        # Alias businessItemeHasProcedureStep with fallback.
        # NB: Currently, business items only have one procedure step
        #
        # @return [Grom::Node, nil] a Procedure Step Grom::Node or nil.
        def procedure_step
          return @procedure_step if @procedure_step
          return nil unless respond_to?(:businessItemHasProcedureStep)

          @procedure_step = Helpers::Utils.type_safe_first(businessItemHasProcedureStep, Parliament::Grom::Decorator::ProcedureStep)
        end

        # Alias businessItemDate with fallback.
        #
        # @return [Date, nil] the date of the Grom::Node or nil.
        def date
          respond_to?(:businessItemDate) ? DateTime.parse(businessItemDate) : nil
        end

        # Alias businessItemHasWorkPackage with fallback.
        #
        # @return [Grom::Node, nil] the WorkPackage of the Grom::Node or nil.
        def work_package
          return @work_package if @work_package

          return nil unless respond_to?(:businessItemHasWorkPackage)

          @work_package = Helpers::Utils.type_safe_first(businessItemHasWorkPackage, Parliament::Grom::Decorator::WorkPackage)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parliament-grom-decorators-1.0.6 lib/parliament/grom/decorator/business_item.rb
parliament-grom-decorators-1.0.5 lib/parliament/grom/decorator/business_item.rb
parliament-grom-decorators-1.0.4 lib/parliament/grom/decorator/business_item.rb