Class: Yoti::DynamicSharingService::WantedAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti/dynamic_share_service/policy/wanted_attribute.rb

Overview

Describes a wanted attribute in a dynamic sharing policy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWantedAttribute

Returns a new instance of WantedAttribute.



11
12
13
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 11

def initialize
  @constraints = []
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints.



9
10
11
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 9

def constraints
  @constraints
end

#derivationObject (readonly)

Returns the value of attribute derivation.



8
9
10
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 8

def derivation
  @derivation
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 7

def name
  @name
end

Class Method Details

.builderObject



35
36
37
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 35

def self.builder
  WantedAttributeBuilder.new
end

Instance Method Details

#accept_self_assertedObject



15
16
17
18
19
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 15

def accept_self_asserted
  return true if @accept_self_asserted

  false
end

#as_json(*_args) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 25

def as_json(*_args)
  obj = {
    name: @name
  }
  obj[:derivation] = @derivation if derivation
  obj[:accept_self_asserted] = @accept_self_asserted if accept_self_asserted
  obj[:constraints] = @constraints.map(&:as_json) unless constraints.empty?
  obj
end

#to_json(*_args) ⇒ Object



21
22
23
# File 'lib/yoti/dynamic_share_service/policy/wanted_attribute.rb', line 21

def to_json(*_args)
  as_json.to_json
end