Sha256: e53dcb7f6706f7ac6d1f3e413ec889c791cb482ee7f193d7ac4ae9259d8af05a

Contents?: true

Size: 1.27 KB

Versions: 38

Compression:

Stored size: 1.27 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/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

38 entries across 38 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.32.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.32.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.31.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.31.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.31.0.pre.rc lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.30.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.29.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.7 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.6 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.5 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.4 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.3 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.2 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.27.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.26.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.25.1 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.25.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.24.0 lib/parliament/grom/decorator/party_membership.rb
parliament-grom-decorators-0.23.0 lib/parliament/grom/decorator/party_membership.rb