Class: Datacaster::ContextNodes::PassIf

Inherits:
Datacaster::ContextNode show all
Defined in:
lib/datacaster/context_nodes/pass_if.rb

Instance Method Summary collapse

Methods inherited from Datacaster::ContextNode

#initialize, #inspect

Methods included from Mixin

#&, #*, #call, #call_with_runtime, #cast_errors, #i18n_key, #i18n_map_keys, #i18n_scope, #i18n_vars, #inspect, #then, #with_context, #with_object_context, #with_runtime, #|

Constructor Details

This class inherits a constructor from Datacaster::ContextNode

Instance Method Details

#cast(object, runtime:) ⇒ Object



4
5
6
7
8
# File 'lib/datacaster/context_nodes/pass_if.rb', line 4

def cast(object, runtime:)
  @runtime = create_runtime(runtime)
  result = @base.with_runtime(@runtime).call(object)
  result.valid? ? Datacaster::ValidResult(object) : result
end