Class: Plumb::StaticClass

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parse, #resolve

Constructor Details

#initialize(value = Undefined) ⇒ StaticClass

Returns a new instance of StaticClass.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/plumb/static_class.rb', line 11

def initialize(value = Undefined)
  raise ArgumentError, 'value must be frozen' unless value.frozen?

  @value = value
  @children = [value].freeze
  freeze
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



9
10
11
# File 'lib/plumb/static_class.rb', line 9

def children
  @children
end

Instance Method Details

#[](value) ⇒ Object



19
20
21
# File 'lib/plumb/static_class.rb', line 19

def [](value)
  self.class.new(value)
end

#call(result) ⇒ Object



23
24
25
# File 'lib/plumb/static_class.rb', line 23

def call(result)
  result.valid(@value)
end