Class: Plumb::AttributeValueMatch

Inherits:
Object
  • Object
show all
Includes:
Composable
Defined in:
lib/plumb/attribute_value_match.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parse, #resolve

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_nameObject (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

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/plumb/attribute_value_match.rb', line 7

def type
  @type
end

#valueObject (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

#metadataObject



18
# File 'lib/plumb/attribute_value_match.rb', line 18

def  = type.