Class: Plumb::Metadata

Inherits:
Object
  • Object
show all
Includes:
Composable
Defined in:
lib/plumb/metadata.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, #value, #where, #with, wrap, #|

Methods included from Callable

#parse, #resolve

Constructor Details

#initialize(type, metadata) ⇒ Metadata

Returns a new instance of Metadata.



9
10
11
12
13
# File 'lib/plumb/metadata.rb', line 9

def initialize(type, )
  @type = type
  @metadata = type..merge()
  freeze
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/plumb/metadata.rb', line 15

def ==(other)
  other.is_a?(self.class) && @metadata == other.
end

#call(result) ⇒ Object



27
# File 'lib/plumb/metadata.rb', line 27

def call(result) = type.call(result)

#metadata(data = Undefined) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/plumb/metadata.rb', line 19

def (data = Undefined)
  if data == Undefined
    @metadata
  else
    Metadata.new(@type, @metadata.merge(data))
  end
end