Class: Restspec::Schema::Types::EmbeddedSchemaType

Inherits:
BasicType
  • Object
show all
Defined in:
lib/restspec/schema/types/embedded_schema_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicType

#of, #totally_valid?, #|

Constructor Details

#initialize(options, options_when_name_is_present = {}) ⇒ EmbeddedSchemaType

Returns a new instance of EmbeddedSchemaType.



5
6
7
8
9
10
11
12
# File 'lib/restspec/schema/types/embedded_schema_type.rb', line 5

def initialize(options, options_when_name_is_present = {})
  if options.is_a?(Symbol)
    self.schema_name = options
    super(options_when_name_is_present)
  else
    super(options)
  end
end

Instance Attribute Details

#schema_nameObject

Returns the value of attribute schema_name.



3
4
5
# File 'lib/restspec/schema/types/embedded_schema_type.rb', line 3

def schema_name
  @schema_name
end

Instance Method Details

#example_for(attribute) ⇒ Object



14
15
16
# File 'lib/restspec/schema/types/embedded_schema_type.rb', line 14

def example_for(attribute)
  Restspec::Schema::SchemaExample.new(schema).value
end

#valid?(attribute, value) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/restspec/schema/types/embedded_schema_type.rb', line 18

def valid?(attribute, value)
  Restspec::Schema::Checker.new(schema).check!(value)
end