Sha256: d98c562ba255e2bef48f1e00da15eb71a6b724a5a73981a7cb05df6c9b2a13ec
Contents?: true
Size: 1022 Bytes
Versions: 5
Compression:
Stored size: 1022 Bytes
Contents
# frozen_string_literal: true require 'plumb/composable' module Plumb # Wrap a policy composition ("step") in a Policy object. # So that visitors such as JSONSchema and Metadata visitors # can define dedicated handlers for policies, if they need to. class Policy include Composable attr_reader :policy_name, :arg, :children # @param policy_name [Symbol] # @param arg [Object, nil] the argument to the policy, if any. # @param step [Step] the step composition wrapped by this policy. def initialize(policy_name, arg, step) @policy_name = policy_name @arg = arg @step = step @children = [step].freeze freeze end def ==(other) other.is_a?(self.class) && policy_name == other.policy_name && arg == other.arg end # The standard Step interface. # @param result [Result::Valid] # @return [Result::Valid, Result::Invalid] def call(result) = @step.call(result) private def _inspect = @step.inspect end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
plumb-0.0.8 | lib/plumb/policy.rb |
plumb-0.0.7 | lib/plumb/policy.rb |
plumb-0.0.6 | lib/plumb/policy.rb |
plumb-0.0.5 | lib/plumb/policy.rb |
plumb-0.0.4 | lib/plumb/policy.rb |