Module: JSON::Schema::Serializer::WithContext

Defined in:
lib/json/schema/serializer.rb

Constant Summary collapse

ARG2_NOT_GIVEN =
:__json_schema_serializer_arg2_not_given__

Instance Method Summary collapse

Instance Method Details

#with_context!(arg1, arg2 = ARG2_NOT_GIVEN) ⇒ Object

rubocop:disable Airbnb/OptArgParameters



27
28
29
30
31
32
33
34
35
# File 'lib/json/schema/serializer.rb', line 27

def with_context!(arg1, arg2 = ARG2_NOT_GIVEN) # rubocop:disable Airbnb/OptArgParameters
  if block_given?
    DataWithContext.new(data: yield, context: arg1)
  elsif arg2 == ARG2_NOT_GIVEN
    DataWithContext.new(arg1)
  else
    DataWithContext.new(data: arg1, context: arg2)
  end
end