Class: TreeFilter::Defer

Inherits:
Struct
  • Object
show all
Includes:
JsonTerminal
Defined in:
lib/tree_filter.rb

Overview

Note:

All data structures containing this object must be filtered before

The wrapped lamda will not be executed unless it is actually required in the filtered response. This can be used for performance optimization, and also to break cycles.

data = {'a' => 1, 'b' => TreeFilter::Defer.new(->{ raise })}

TreeFilter.new("a").filter(data) # => {'a' => 1}
TreeFilter.new("b").filter(data) # => raise

converting to JSON, otherwise you will get a stack overflow error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonTerminal

#as_json

Instance Attribute Details

#fObject

Returns the value of attribute f

Returns:

  • (Object)

    the current value of f


61
62
63
# File 'lib/tree_filter.rb', line 61

def f
  @f
end

Instance Method Details

#callObject


64
65
66
# File 'lib/tree_filter.rb', line 64

def call
  f.call
end