Sha256: 18041960189add3343a8c65f9c83561855d2fe560a197d78c39ccc7dac1d0cfc

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

module Sandbox
  # Attribute describes an attribute on a sandbox profile
  class Attribute
    attr_accessor :name
    attr_accessor :value
    attr_accessor :derivation
    attr_accessor :optional
    attr_reader :anchors

    def initialize(
      name: '',
      value: '',
      derivation: '',
      optional: false,
      anchors: []
    )
      @name = name
      @value = value
      @derivation = derivation
      @optional = optional
      @anchors = anchors
    end

    def as_json(*_args)
      {
        name: name,
        value: value,
        derivation: derivation,
        optional: optional,
        anchors: anchors
      }
    end

    def with_anchor(anchor)
      @anchors.push anchor
      self
    end
  end

  # Helper functions for building derivation strings
  module Derivation
    def self.age_over(age)
      "age_over:#{age}"
    end

    def self.age_under(age)
      "age_under:#{age}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yoti-1.6.2 lib/yoti/sandbox/attribute.rb
yoti-1.6.1 lib/yoti/sandbox/attribute.rb
yoti-1.6.0 lib/yoti/sandbox/attribute.rb