Sha256: ddc8c00ed3280394466a32616574bb6dafbcdd1b985e846daa8f46ca124bfa56

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/House
      module House
        # Alias houseName with fallback.
        #
        # @return [String, String] the name of the Grom::Node or an empty string.
        def name
          respond_to?(:houseName) ? houseName : ''
        end

        # Alias houseSeatHasSeatIncumbency with fallback.
        #
        # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
        def seat_incumbencies
          return @seat_incumbencies unless @seat_incumbencies.nil?

          seat_incumbencies = []
          seats.each do |seat|
            seat_incumbencies << seat.seat_incumbencies
          end

          @seat_incumbencies = seat_incumbencies.flatten.uniq
        end

        # Alias houseHasHouseSeat with fallback.
        #
        # @return [Array, Array] the house seats of the Grom::Node or an empty array.
        def seats
          respond_to?(:houseHasHouseSeat) ? houseHasHouseSeat : []
        end

        # Alias houseHasHouseIncumbency with fallback.
        #
        # @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
        def house_incumbencies
          respond_to?(:houseHasHouseIncumbency) ? houseHasHouseIncumbency : []
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.21.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.19.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.18.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.17.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.16.4 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.16.3 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.16.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.16.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.15.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.14.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.14.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.13.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.12.1 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.12.0 lib/parliament/grom/decorator/house.rb
parliament-grom-decorators-0.11.0 lib/parliament/grom/decorator/house.rb