class Yoti::DynamicSharingService::SourceConstraintBuilder

Builder for SourceConstraint

Public Class Methods

new() click to toggle source
# File lib/yoti/dynamic_share_service/policy/source_constraint.rb, line 48
def initialize
  @constraint = SourceConstraint.new
end

Public Instance Methods

build() click to toggle source
# File lib/yoti/dynamic_share_service/policy/source_constraint.rb, line 83
def build
  Marshal.load Marshal.dump @constraint
end
with_anchor(anchor) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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