Class: Yoti::DynamicSharingService::SourceConstraintBuilder

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

Overview

Builder for SourceConstraint

Instance Method Summary collapse

Constructor Details

#initializeSourceConstraintBuilder

Returns a new instance of SourceConstraintBuilder.



48
49
50
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 48

def initialize
  @constraint = SourceConstraint.new
end

Instance Method Details

#buildObject



83
84
85
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 83

def build
  Marshal.load Marshal.dump @constraint
end

#with_anchor(anchor) ⇒ Object



57
58
59
60
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 57

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

#with_anchor_by_value(value, sub_type) ⇒ Object



52
53
54
55
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 52

def with_anchor_by_value(value, sub_type)
  anchor = WantedAnchor.builder.with_value(value).with_sub_type(sub_type).build
  with_anchor(anchor)
end

#with_driving_licence(sub_type = nil) ⇒ Object



66
67
68
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 66

def with_driving_licence(sub_type = nil)
  with_anchor_by_value(SourceConstraint::DRIVING_LICENCE, sub_type)
end

#with_national_id(sub_type = nil) ⇒ Object



70
71
72
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 70

def with_national_id(sub_type = nil)
  with_anchor_by_value(SourceConstraint::NATIONAL_ID, sub_type)
end

#with_passcard(sub_type = nil) ⇒ Object



74
75
76
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 74

def with_passcard(sub_type = nil)
  with_anchor_by_value(SourceConstraint::PASS_CARD, sub_type)
end

#with_passport(sub_type = nil) ⇒ Object



62
63
64
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 62

def with_passport(sub_type = nil)
  with_anchor_by_value(SourceConstraint::PASSPORT, sub_type)
end

#with_soft_preference(preference = true) ⇒ Object



78
79
80
81
# File 'lib/yoti/dynamic_share_service/policy/source_constraint.rb', line 78

def with_soft_preference(preference = true)
  @constraint.instance_variable_set(:@soft_preference, preference)
  self
end