Class: JsonModel::TypeSpec::Object

Inherits:
JsonModel::TypeSpec show all
Defined in:
lib/json_model/type_spec/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from JsonModel::TypeSpec

#register_validations, resolve

Constructor Details

#initialize(type) ⇒ Object

Returns a new instance of Object.

Parameters:



9
10
11
12
# File 'lib/json_model/type_spec/object.rb', line 9

def initialize(type)
  super()
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/json_model/type_spec/object.rb', line 6

def type
  @type
end

Instance Method Details

#as_schema(**options) ⇒ Hash

Parameters:

  • options (Hash)

Returns:

  • (Hash)


16
17
18
# File 'lib/json_model/type_spec/object.rb', line 16

def as_schema(**options)
  type.as_schema(**options)
end

#cast(json) ⇒ ::Object?

Parameters:

  • json (::Object)

Returns:

  • (::Object, nil)


27
28
29
# File 'lib/json_model/type_spec/object.rb', line 27

def cast(json)
  type.from_json(**json)
end

#referenced_schemasArray<TypeSpec>

Returns:



21
22
23
# File 'lib/json_model/type_spec/object.rb', line 21

def referenced_schemas
  [type]
end