Class: Restspec::Schema::Types::SchemaIdType
- Inherits:
-
BasicType
- Object
- BasicType
- Restspec::Schema::Types::SchemaIdType
show all
- Defined in:
- lib/restspec/schema/types/schema_id_type.rb
Instance Method Summary
collapse
Methods inherited from BasicType
#of, #to_s, #totally_valid?, #|
Constructor Details
#initialize(schema_name, options = {}) ⇒ SchemaIdType
4
5
6
7
|
# File 'lib/restspec/schema/types/schema_id_type.rb', line 4
def initialize(schema_name, options = {})
self.schema_name = schema_name
super(options)
end
|
Instance Method Details
#example_for(attribute) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/restspec/schema/types/schema_id_type.rb', line 9
def example_for(attribute)
return sample_item[id_property] if sample_item.present?
if create_response.code == 201 && value = response_property_value(create_response, id_property)
value
else
hardcoded_fallback
end
rescue URI::InvalidURIError, Errno::ECONNREFUSED => e
hardcoded_fallback
end
|
#valid?(attribute, value) ⇒ Boolean
21
22
23
24
|
# File 'lib/restspec/schema/types/schema_id_type.rb', line 21
def valid?(attribute, value)
return true unless perform_validation?
item_ids.any? { |item| item[id_property] == value }
end
|