Sha256: cf597cbd168c160973b556e6b086cd782e122f9fb456443993533b84cb28684c

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Laying
      module Laying
        # Alias layingDate with fallback.
        #
        # @return [Date, nil] the date of the Grom::Node or nil.
        def date
          respond_to?(:layingDate) ? DateTime.parse(layingDate) : nil
        end

        # Alias layingHasLayingBody with fallback.
        #
        # @return [Grom::Node, nil] the LayingBody of the Grom::Node or nil.
        def body
          return @body if @body
          return nil unless respond_to?(:layingHasLayingBody)

          @body = Helpers::Utils.type_safe_first(layingHasLayingBody, Parliament::Grom::Decorator::Group)
        end

        # Alias layingHasLayingPerson with fallback.
        #
        # @return [Grom::Node, nil] the LayingPerson of the Grom::Node or nil.
        def person
          return @person if @person
          return nil unless respond_to?(:layingHasLayingPerson)

          @person = Helpers::Utils.type_safe_first(layingHasLayingPerson, Parliament::Grom::Decorator::Person)
        end

        # Alias layingHasLaidThing with fallback.
        #
        # @return [Grom::Node, nil] the LaidThing of the Grom::Node or nil.
        def laid_thing
          return @laid_thing if @laid_thing
          return nil unless respond_to?(:layingHasLaidThing)

          @laid_thing = Helpers::Utils.type_safe_first(layingHasLaidThing, Parliament::Grom::Decorator::LaidThing)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parliament-grom-decorators-1.0.4 lib/parliament/grom/decorator/laying.rb
parliament-grom-decorators-1.0.3 lib/parliament/grom/decorator/laying.rb
parliament-grom-decorators-1.0.2 lib/parliament/grom/decorator/laying.rb