Sha256: 7cf85774cac53ecd68baf76e9e3814141d4db5ce73e9645284e1638f55a6ed4d

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/FormalBodyMembership.
      # rubocop:disable ModuleLength
      module FormalBodyMembership
        include Helpers::DateHelper

        # Alias formalBodyMembershipStartDate with fallback.
        #
        # @return [DateTime, nil] the start date of the Grom::Node or nil.
        def start_date
          @start_date ||= respond_to?(:formalBodyMembershipStartDate) ? DateTime.parse(formalBodyMembershipStartDate) : nil
        end

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

        # Checks if Grom::Node has an end date.
        #
        # @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
        def current?
          end_date.nil?
        end

        # Alias formalBodyMembershipFormalBody with fallback.
        #
        # @return [Grom::Node, nil] the start date of the Grom::Node or nil.
        def formal_body
          respond_to?(:formalBodyMembershipHasFormalBody) ? formalBodyMembershipHasFormalBody&.first : nil
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.10.1 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.10.0 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.9.0 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.8.0 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.7.0 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.6.1 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.6.0 lib/parliament/grom/decorator/formal_body_membership.rb
parliament-grom-decorators-0.4.0 lib/parliament/grom/decorator/formal_body_membership.rb