Sha256: ebe309bd4fc53651cc890eb4a4fca3127b5fe896c546c204b859f023ec20cb14

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

module Ddr
  module Auth
    # @abstract
    class Affiliation < SimpleDelegator      

      private_class_method :new

      VALUES = [:faculty, :staff, :student, :emeritus, :affiliate, :alumni]

      VALUES.each do |value|
        const_set(value.to_s.capitalize, new(value))
      end

      def group
        Group.new("duke.#{self}")
      end

      def inspect
        "#<#{self.class.name}(#{self})>"
      end        

      class << self
        def all
          @all ||= VALUES.map { |value| get(value) }
        end

        def get(affiliation)
          const_get(affiliation.to_s.capitalize)
        end

        def group(affiliation)
          get(affiliation).group
        end

        def groups
          @groups ||= all.map(&:group)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddr-models-1.13.2 lib/ddr/auth/affiliation.rb