Class: Plumb::Policy
Overview
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.
Instance Attribute Summary collapse
-
#arg ⇒ Object
readonly
Returns the value of attribute arg.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#policy_name ⇒ Object
readonly
Returns the value of attribute policy_name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#call(result) ⇒ Result::Valid, Result::Invalid
The standard Step interface.
-
#initialize(policy_name, arg, step) ⇒ Policy
constructor
A new instance of Policy.
Methods included from Composable
#>>, #[], #as_node, #build, #check, #defer, #generate, included, #invalid, #invoke, #match, #metadata, #not, #pipeline, #policy, #static, #to_json_schema, #to_s, #transform, #value, wrap, #|
Methods included from Callable
Constructor Details
#initialize(policy_name, arg, step) ⇒ Policy
Returns a new instance of Policy.
17 18 19 20 21 22 23 |
# File 'lib/plumb/policy.rb', line 17 def initialize(policy_name, arg, step) @policy_name = policy_name @arg = arg @step = step @children = [step].freeze freeze end |
Instance Attribute Details
#arg ⇒ Object (readonly)
Returns the value of attribute arg.
12 13 14 |
# File 'lib/plumb/policy.rb', line 12 def arg @arg end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
12 13 14 |
# File 'lib/plumb/policy.rb', line 12 def children @children end |
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
12 13 14 |
# File 'lib/plumb/policy.rb', line 12 def policy_name @policy_name end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 |
# File 'lib/plumb/policy.rb', line 25 def ==(other) other.is_a?(self.class) && policy_name == other.policy_name && arg == other.arg end |
#call(result) ⇒ Result::Valid, Result::Invalid
The standard Step interface.
34 |
# File 'lib/plumb/policy.rb', line 34 def call(result) = @step.call(result) |