Sha256: a497c79223b4873737132ad5af2540431546932c48d32ed03a87930327d8ef74

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ContactPoint
      module ContactPoint
        # Alias contactPointHasPostalAddress with fallback.
        #
        # @return [Array, Array] an array of the postal addresses for the Grom::Node or an empty array.
        def postal_addresses
          respond_to?(:contactPointHasPostalAddress) ? contactPointHasPostalAddress : []
        end

        # Alias email with fallback.
        #
        # @return [String, String] the email of the Grom::Node or an empty string.
        def email
          instance_variable_get('@email'.to_sym).nil? ? '' : instance_variable_get('@email'.to_sym)
        end

        # Alias phoneNumber with fallback.
        #
        # @return [String, String] the phone number of the Grom::Node or an empty string.
        def phone_number
          respond_to?(:phoneNumber) ? phoneNumber : ''
        end

        # Alias faxNumber with fallback.
        #
        # @return [String, String] the fax number of the Grom::Node or an empty string.
        def fax_number
          respond_to?(:faxNumber) ? faxNumber : ''
        end

        # Alias contactPointHasPerson with fallback.
        #
        # @return [Array, Array] the person connected to the Grom::Node or an empty array.
        def person
          respond_to?(:contactPointHasPerson) ? contactPointHasPerson : []
        end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.10.1 lib/parliament/grom/decorator/contact_point.rb
parliament-grom-decorators-0.10.0 lib/parliament/grom/decorator/contact_point.rb