Module: Parliament::Grom::Decorator::WorkPackageableThing

Includes:
Helpers::DateHelper
Defined in:
lib/parliament/grom/decorator/work_packageable_thing.rb

Overview

Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/WorkPackageableThing

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#nameString

Alias workPackageableThingName with fallback.

Returns:

  • (String, String)

    the name of the Grom::Node or an empty string.

Since:

  • 0.1.0



10
11
12
# File 'lib/parliament/grom/decorator/work_packageable_thing.rb', line 10

def name
  respond_to?(:workPackageableThingName) ? workPackageableThingName : ''
end

#time_limit_for_objection_dateDateTime?

Alias workPackageableThingComingIntoForceDate with fallback.

Returns:

  • (DateTime, nil)

    the expiry date (time limit) of a work package or nil.

Since:

  • 0.1.0



37
38
39
# File 'lib/parliament/grom/decorator/work_packageable_thing.rb', line 37

def time_limit_for_objection_date
  respond_to?(:workPackageableThingTimeLimitForObjectionEndDate) ? DateTime.parse(workPackageableThingTimeLimitForObjectionEndDate) : nil
end

Alias workPackageableThingHasWorkPackage with fallback.

Returns:

  • (String, String)

    a web link or an empty string.

Since:

  • 0.1.0



25
26
27
# File 'lib/parliament/grom/decorator/work_packageable_thing.rb', line 25

def weblink
  respond_to?(:workPackageableThingHasWorkPackageableThingWebLink) ? workPackageableThingHasWorkPackageableThingWebLink : ''
end

#work_packageGrom::Node?

Alias workPackageableThingHasWorkPackage with fallback. NB: Currently, a work packageable thing only has one work package

Returns:

  • (Grom::Node, nil)

    a WorkPackage Grom::Node or nil.

Since:

  • 0.1.0



18
19
20
# File 'lib/parliament/grom/decorator/work_packageable_thing.rb', line 18

def work_package
  respond_to?(:workPackageableThingHasWorkPackage) ? workPackageableThingHasWorkPackage.first : nil
end