Sha256: ee219315f94bc4e560f85a35aa9b814221236eaab7cdd78d71284fd50331ff7e

Contents?: true

Size: 905 Bytes

Versions: 5

Compression:

Stored size: 905 Bytes

Contents

module Yoti
  #
  # Encapsulates Yoti user profile
  #
  class BaseProfile
    #
    # Return all attributes for the profile.
    #
    # @return [Hash{String => Yoti::Attribute}]
    #
    attr_reader :attributes

    #
    # @param [Hash{String => Yoti::Attribute}] profile_data
    #
    def initialize(profile_data)
      @attributes = profile_data.is_a?(Object) ? profile_data : {}
    end

    #
    # Get attribute value by name.
    #
    # @param [String] attr_name
    #
    # @return [Attribute, nil]
    #
    def get_attribute(attr_name)
      return nil unless @attributes.key? attr_name

      @attributes[attr_name]
    end

    protected

    #
    # Find attributes starting with provided name.
    #
    # @param [String] name
    #
    # @returns [Array]
    #
    def find_attributes_starting_with(name)
      @attributes.select { |key| key.to_s.start_with?(name) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yoti-1.6.4 lib/yoti/data_type/base_profile.rb
yoti-1.6.3 lib/yoti/data_type/base_profile.rb
yoti-1.6.2 lib/yoti/data_type/base_profile.rb
yoti-1.6.1 lib/yoti/data_type/base_profile.rb
yoti-1.6.0 lib/yoti/data_type/base_profile.rb