Class: Parametric::PolicyAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/parametric/policy_adapter.rb

Overview

Adapt legacy policies to the new policy interface

Defined Under Namespace

Classes: PolicyRunner

Instance Method Summary collapse

Constructor Details

#initialize(policy) ⇒ PolicyAdapter

Returns a new instance of PolicyAdapter.



41
42
43
# File 'lib/parametric/policy_adapter.rb', line 41

def initialize(policy)
  @policy = policy
end

Instance Method Details

#==(other) ⇒ Object



65
66
67
# File 'lib/parametric/policy_adapter.rb', line 65

def ==(other)
  key == other.key &&  == other.
end

#build(key, value, payload:, context:) ⇒ PolicyRunner

The PolicyFactory interface Buld a Policy Runner, which is instantiated for each field when resolving a schema

Parameters:

  • key (Symbol)
  • value (Any)
  • payload (Hash)

    a customizable set of options

  • context (Hash)

    a customizable set of options

Options Hash (payload:):

  • (Hash)

Options Hash (context:):

Returns:



53
54
55
# File 'lib/parametric/policy_adapter.rb', line 53

def build(key, value, payload:, context:)
  PolicyRunner.new(@policy, key, value, payload, context)
end

#keyObject



61
62
63
# File 'lib/parametric/policy_adapter.rb', line 61

def key
  @policy.key
end

#meta_dataObject



57
58
59
# File 'lib/parametric/policy_adapter.rb', line 57

def 
  @policy.
end