Module: Foobara::TypeDeclarations

Defined in:
foobara-0.1.7/projects/type_declarations/src/caster.rb,
foobara-0.1.7/projects/type_declarations/src/processor.rb,
foobara-0.1.7/projects/type_declarations/src/validator.rb,
foobara-0.1.7/projects/type_declarations/src/attributes.rb,
foobara-0.1.7/projects/type_declarations/src/desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/transformer.rb,
foobara-0.1.7/projects/type_declarations/src/type_builder.rb,
foobara-0.1.7/projects/type_declarations/src/dsl/attributes.rb,
foobara-0.1.7/projects/type_declarations/src/error_extension.rb,
foobara-0.1.7/projects/type_declarations/src/with_registries.rb,
foobara-0.1.7/projects/type_declarations/src/element_processor.rb,
foobara-0.1.7/projects/type_declarations/src/type_declarations.rb,
foobara-0.1.7/projects/type_declarations/src/typed_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/to_type_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/desugarizer_pipeline.rb,
foobara-0.1.7/projects/type_declarations/src/sensitive_type_remover.rb,
foobara-0.1.7/projects/type_declarations/src/type_declaration_error.rb,
foobara-0.1.7/projects/type_declarations/src/lazy_element_types/hash.rb,
foobara-0.1.7/projects/type_declarations/src/lazy_element_types/array.rb,
foobara-0.1.7/projects/type_declarations/src/lazy_element_types/tuple.rb,
foobara-0.1.7/projects/type_declarations/src/type_declaration_handler.rb,
foobara-0.1.7/projects/type_declarations/lib/foobara/type_declarations.rb,
foobara-0.1.7/projects/type_declarations/src/type_declaration_validator.rb,
foobara-0.1.7/projects/type_declarations/src/lazy_element_types/attributes.rb,
foobara-0.1.7/projects/type_declarations/src/sensitive_type_removers/array.rb,
foobara-0.1.7/projects/type_declarations/src/sensitive_value_removers/array.rb,
foobara-0.1.7/projects/type_declarations/src/type_declaration_handler_registry.rb,
foobara-0.1.7/projects/type_declarations/src/sensitive_type_removers/attributes.rb,
foobara-0.1.7/projects/type_declarations/src/remove_sensitive_values_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/sensitive_value_removers/attributes.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/registered_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_array_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_tuple_type_declaration.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_attributes_type_declaration/hash_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_attributes_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/hash_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/model_class_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/primary_key_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/key_type_declaration_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb,
foobara-0.1.7/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/value_type_declaration_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/attributes_handler_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_is_symbol.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/hash_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/to_type_transformer.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/model_class_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/primary_key_desugarizer.rb,
foobara-0.1.7/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_references_attribute.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_present.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/attributes_handler_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb,
foobara-0.1.7/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb,
foobara-0.1.7/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_references_attribute.rb

Defined Under Namespace

Modules: Attributes, Dsl, ErrorExtension, Handlers, LazyElementTypes, Mode, SensitiveTypeRemovers, SensitiveValueRemovers, WithRegistries Classes: Caster, Desugarizer, DesugarizerPipeline, ElementProcessor, Processor, RemoveSensitiveValuesTransformer, SensitiveTypeRemover, ToTypeTransformer, Transformer, TypeBuilder, TypeDeclarationError, TypeDeclarationHandler, TypeDeclarationHandlerRegistry, TypeDeclarationValidator, TypedTransformer, Validator

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.validate_error_context_enabledObject

Returns the value of attribute validate_error_context_enabled.



4
5
6
# File 'foobara-0.1.7/projects/type_declarations/src/error_extension.rb', line 4

def validate_error_context_enabled
  @validate_error_context_enabled
end

Class Method Details

.args_to_type_declaration(*args, &block) ⇒ Object

TODO: relocate these to a different file



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'foobara-0.1.7/projects/type_declarations/src/type_builder.rb', line 7

def args_to_type_declaration(*args, &block)
  if block
    if args.empty? || args == [:attributes]
      TypeDeclaration.new(block)
    elsif args == [:array]
      type_declaration = TypeDeclaration.new(type: :array, element_type_declaration: block)
      type_declaration.is_absolutified = true
      type_declaration.is_duped = true
      type_declaration.is_deep_duped = true
      type_declaration
    else
      # :nocov:
      raise ArgumentError, "Cannot provide both block and declaration of #{args}"
      # :nocov:
    end
  else
    case args.size
    when 0
      # :nocov:
      raise ArgumentError, "expected 1 argument or a block but got 0 arguments and no block"
      # :nocov:
    when 1
      arg = args.first

      if arg.is_a?(TypeDeclaration)
        arg
      else
        TypeDeclaration.new(arg)
      end
    else
      type, *symbolic_processors, processor_data = args

      type_declaration = if !symbolic_processors.empty?
                           symbolic_processors = symbolic_processors.to_h { |symbol| [symbol, true] }

                           if processor_data.is_a?(::Hash) && !processor_data.empty?
                             h = processor_data.merge(symbolic_processors)
                             h[:type] = type
                             TypeDeclaration.new(h)
                           else
                             type_declaration = TypeDeclaration.new(symbolic_processors.merge(type:))
                             type_declaration.is_deep_duped = true
                             type_declaration
                           end
                         elsif processor_data.is_a?(::Hash)
                           TypeDeclaration.new(processor_data.merge(type:))
                         else
                           h = { type:, processor_data.to_sym => true }
                           type_declaration = TypeDeclaration.new(h)
                           type_declaration.is_deep_duped = true
                           type_declaration
                         end

      type_declaration.is_duped = true
      type_declaration
    end
  end
end

.capture_current_namespacesObject



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'foobara-0.1.7/projects/type_declarations/lib/foobara/type_declarations.rb', line 131

def capture_current_namespaces
  # TODO: this feels like the wrong place to do this but doing it here for now to make sure it's done when
  # most important
  @original_scoped = Namespace.global.foobara_registry.all_scoped.dup
  @original_children = Namespace.global.foobara_children.dup

  if GlobalDomain.const_defined?(:Types, false)
    # :nocov:
    @original_foobara_lowercase_constants =
      GlobalDomain::Types.instance_variable_get(:@foobara_lowercase_constants).dup
    # :nocov:
  end
end

.declarations_equal?(declaration1, declaration2) ⇒ Boolean

TODO: we should desugarize these but can’t because of a bug where desugarizing entities results in creating the entity class in memory, whoops.

Returns:

  • (Boolean)


108
109
110
111
112
113
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 108

def declarations_equal?(declaration1, declaration2)
  declaration1 = declaration1.reject { |(k, _v)| k.to_s.start_with?("_") }.to_h
  declaration2 = declaration2.reject { |(k, _v)| k.to_s.start_with?("_") }.to_h

  declaration1 == declaration2
end

.foobara_manifest_contextObject



115
116
117
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 115

def foobara_manifest_context
  Thread.inheritable_thread_local_var_get("foobara_manifest_context")
end

.global_type_declaration_handler_registryObject



15
16
17
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 15

def global_type_declaration_handler_registry
  GlobalDomain.foobara_type_builder.type_declaration_handler_registry
end

.include_processors?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 102

def include_processors?
  foobara_manifest_context_include_processors?
end

.install!Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'foobara-0.1.7/projects/type_declarations/lib/foobara/type_declarations.rb', line 85

def install!
  capture_current_namespaces

  reset_all(skip_check: true)

  Foobara::Error.include(ErrorExtension)

  Value::Processor::Casting::CannotCastError.singleton_class.define_method :context_type_declaration do
    {
      cast_to: :duck,
      value: :duck,
      attribute_name: :symbol
    }
  end

  Value::Processor::Selection::NoApplicableProcessorError.singleton_class.define_method(
    :context_type_declaration
  ) do
    {
      processor_names: [:symbol],
      value: :duck
    }
  end

  Value::Processor::Selection::MoreThanOneApplicableProcessorError.singleton_class.define_method(
    :context_type_declaration
  ) do
    {
      applicable_processor_names: [:symbol],
      processor_names: [:symbol],
      value: :duck
    }
  end

  Value::DataError.singleton_class.define_method :context_type_declaration do
    {
      attribute_name: :symbol,
      value: :duck
    }
  end
end

.manifest_context_set?(context_item) ⇒ Boolean

Returns:

  • (Boolean)


134
135
136
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 134

def manifest_context_set?(context_item)
  foobara_manifest_context&.key?(context_item)
end

.new_project_added(_project) ⇒ Object



127
128
129
# File 'foobara-0.1.7/projects/type_declarations/lib/foobara/type_declarations.rb', line 127

def new_project_added(_project)
  capture_current_namespaces
end

.register_sensitive_type_remover(sensitive_type_remover) ⇒ Object



23
24
25
26
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 23

def register_sensitive_type_remover(sensitive_type_remover)
  handler = sensitive_type_remover.handler
  sensitive_type_removers[handler.class.name] = sensitive_type_remover
end

.register_sensitive_value_remover(handler, sensitive_value_remover) ⇒ Object

TODO: since these are dealing with values instead of declarations maybe this should live somewhere else?



48
49
50
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 48

def register_sensitive_value_remover(handler, sensitive_value_remover)
  sensitive_value_removers[handler.class.name] = sensitive_value_remover
end

.register_type_declaration(type_declaration_handler) ⇒ Object



19
20
21
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 19

def register_type_declaration(type_declaration_handler)
  global_type_declaration_handler_registry.register(type_declaration_handler)
end

.remove_sensitive_types(strict_type_declaration) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 32

def remove_sensitive_types(strict_type_declaration)
  declaration = TypeDeclaration.new(strict_type_declaration)
  declaration.is_strict = true

  handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)

  sensitive_type_remover = sensitive_type_removers[handler.class.name]

  if sensitive_type_remover&.applicable?(strict_type_declaration)
    sensitive_type_remover.process_value!(strict_type_declaration)
  else
    strict_type_declaration
  end
end

.reset_all(skip_check: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'foobara-0.1.7/projects/type_declarations/lib/foobara/type_declarations.rb', line 4

def reset_all(skip_check: nil)
  unless skip_check
    Foobara.raise_if_production!("reset_all")
  end

  # TODO: this doesn't really belong here. I think we need to maybe call reset in reverse order?
  Foobara::Domain::DomainModuleExtension.all.each do |domain|
    var = "@foobara_type_builder"

    if domain.instance_variable_defined?(var)
      domain.remove_instance_variable(var)
    end
  end

  Util.descendants(Error).each do |error_class|
    if error_class.instance_variable_defined?(:@context_type)
      error_class.remove_instance_variable(:@context_type)
    end
  end

  [
    "foobara_children",
    "foobara_registry",
    "foobara_type_builder"
  ].each do |var_name|
    var_name = "@#{var_name}"

    # Don't we only have to do this for Foobara and not all of these??
    [
      Namespace.global,
      Foobara::GlobalOrganization,
      Foobara::GlobalDomain,
      Domain,
      Command,
      Types::Type,
      Value::Processor,
      Error
    ].each do |klass|
      klass.remove_instance_variable(var_name) if klass.instance_variable_defined?(var_name)
    end
  end

  if GlobalDomain.const_defined?(:Types, false)
    GlobalDomain::Types.instance_variable_set(
      :@foobara_lowercase_constants,
      @original_foobara_lowercase_constants || []
    )
    GlobalDomain.send(:remove_const, :Types)
  end

  @original_scoped.each do |scoped|
    Namespace.global.foobara_register(scoped)
  end

  @original_children.each do |child|
    Namespace.global.foobara_children << child
  end

  GlobalDomain.foobara_parent_namespace = GlobalOrganization
  GlobalOrganization.foobara_register(GlobalDomain)

  register_type_declaration(Handlers::RegisteredTypeDeclaration.new)
  register_type_declaration(Handlers::ExtendRegisteredTypeDeclaration.new)
  array_handler = Handlers::ExtendArrayTypeDeclaration.new
  register_type_declaration(array_handler)
  register_type_declaration(Handlers::ExtendAssociativeArrayTypeDeclaration.new)
  attributes_handler = Handlers::ExtendAttributesTypeDeclaration.new
  register_type_declaration(attributes_handler)
  register_type_declaration(Handlers::ExtendTupleTypeDeclaration.new)

  @sensitive_type_removers = nil

  register_sensitive_type_remover(SensitiveTypeRemovers::Attributes.new(attributes_handler))
  register_sensitive_value_remover(attributes_handler, SensitiveValueRemovers::Attributes)
  register_sensitive_type_remover(SensitiveTypeRemovers::Array.new(array_handler))
  register_sensitive_value_remover(array_handler, SensitiveValueRemovers::Array)

  Foobara::AttributesTransformers::Reject.foobara_unregister_all
  Foobara::AttributesTransformers::Only.foobara_unregister_all
end

.sensitive_type_removersObject



28
29
30
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 28

def sensitive_type_removers
  @sensitive_type_removers ||= {}
end

.sensitive_value_remover_class_for_type(type) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 56

def sensitive_value_remover_class_for_type(type)
  declaration_data = type.declaration_data
  declaration = TypeDeclaration.new(declaration_data)
  declaration.is_strict = true

  handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)
  remover_class = sensitive_value_removers[handler.class.name]

  unless remover_class
    # :nocov:
    raise "No sensitive value remover found for #{declaration_data}"
    # :nocov:
  end

  remover_class
end

.sensitive_value_removersObject



52
53
54
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 52

def sensitive_value_removers
  @sensitive_value_removers ||= {}
end

.strictObject



73
74
75
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 73

def strict(&)
  using_mode(Mode::STRICT, &)
end

.strict?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 90

def strict?
  foobara_manifest_context_mode == Mode::STRICT
end

.strict_stringifiedObject



77
78
79
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 77

def strict_stringified(&)
  using_mode(Mode::STRICT_STRINGIFIED, &)
end

.strict_stringified?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 94

def strict_stringified?
  foobara_manifest_context_mode == Mode::STRICT_STRINGIFIED
end

.stringifiedObject



81
82
83
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 81

def stringified(&)
  using_mode(Mode::STRINGIFIED, &)
end

.stringified?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 98

def stringified?
  foobara_manifest_context_mode == Mode::STRINGIFIED || strict_stringified?
end

.using_mode(new_mode) ⇒ Object

TODO: use manifest context instead



86
87
88
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 86

def using_mode(new_mode, &)
  with_manifest_context(mode: new_mode, &)
end

.validate_error_context_enabled?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'foobara-0.1.7/projects/type_declarations/src/error_extension.rb', line 6

def validate_error_context_enabled?
  validate_error_context_enabled
end

.with_manifest_context(context) ⇒ Object



138
139
140
141
142
143
144
145
146
147
# File 'foobara-0.1.7/projects/type_declarations/src/type_declarations.rb', line 138

def with_manifest_context(context)
  old_context = foobara_manifest_context
  begin
    new_context = (old_context || {}).merge(context)
    Thread.inheritable_thread_local_var_set("foobara_manifest_context", new_context)
    yield
  ensure
    Thread.inheritable_thread_local_var_set("foobara_manifest_context", old_context)
  end
end

.with_validate_error_context_disabledObject



10
11
12
13
14
15
16
17
18
19
# File 'foobara-0.1.7/projects/type_declarations/src/error_extension.rb', line 10

def with_validate_error_context_disabled
  old_enabled = validate_error_context_enabled

  begin
    self.validate_error_context_enabled = false
    yield
  ensure
    self.validate_error_context_enabled = old_enabled
  end
end