Sha256: a53afae3bc087a50313c9c36a09e6df2da4ace16480b4c587950fc134f8611f8

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 KB

Contents

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

        # Alias partyMembershipHasParty with fallback.
        #
        # @return [Grom::Node, nil] the party of the Grom::Node or nil.
        def party
          respond_to?(:partyMembershipHasParty) ? partyMembershipHasParty.first : nil
        end

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

        # Alias partyMembershipEndDate with fallback.
        #
        # @return [DateTime, nil] the end date of the Grom::Node or nil.
        def end_date
          @end_date ||= respond_to?(:partyMembershipEndDate) ? DateTime.parse(partyMembershipEndDate) : 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
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.10.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.10.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.9.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.8.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.7.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.6.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.6.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.4.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.3.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.8 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.7 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.6.pre lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.5.pre lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.4.pre lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.3 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.2.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.1.8 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.1.7 lib/parliament/grom/decorator/party_membership.rb