Class: Plumb::AttributeValueMatch
- Inherits:
-
Object
- Object
- Plumb::AttributeValueMatch
- Includes:
- Composable
- Defined in:
- lib/plumb/attribute_value_match.rb
Instance Attribute Summary collapse
-
#attr_name ⇒ Object
readonly
Returns the value of attribute attr_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #call(result) ⇒ Object
-
#initialize(type, attr_name, value) ⇒ AttributeValueMatch
constructor
A new instance of AttributeValueMatch.
- #metadata ⇒ Object
Methods included from Composable
#>>, #[], #as_node, #build, #check, #children, #defer, #generate, included, #invalid, #invoke, #match, #not, #pipeline, #policy, #static, #to_json_schema, #to_s, #transform, #where, #with, wrap, #|
Methods included from Callable
Constructor Details
#initialize(type, attr_name, value) ⇒ AttributeValueMatch
Returns a new instance of AttributeValueMatch.
9 10 11 12 13 14 15 16 |
# File 'lib/plumb/attribute_value_match.rb', line 9 def initialize(type, attr_name, value) @type = type @attr_name = attr_name @value = value @error = "must have attribute #{attr_name} === #{value.inspect}" @inspect_line = %((#{attr_name} === #{value.inspect})) freeze end |
Instance Attribute Details
#attr_name ⇒ Object (readonly)
Returns the value of attribute attr_name.
7 8 9 |
# File 'lib/plumb/attribute_value_match.rb', line 7 def attr_name @attr_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/plumb/attribute_value_match.rb', line 7 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/plumb/attribute_value_match.rb', line 7 def value @value end |
Instance Method Details
#call(result) ⇒ Object
20 21 22 23 24 |
# File 'lib/plumb/attribute_value_match.rb', line 20 def call(result) return result if value === result.value.public_send(attr_name) result.invalid(errors: @error) end |
#metadata ⇒ Object
18 |
# File 'lib/plumb/attribute_value_match.rb', line 18 def = type. |