Class: Restspec::Schema::Types::SchemaIdType
- Defined in:
- lib/restspec/schema/types/schema_id_type.rb
Instance Method Summary collapse
- #example_for(attribute) ⇒ Object
-
#initialize(schema_name, options = {}) ⇒ SchemaIdType
constructor
A new instance of SchemaIdType.
- #valid?(attribute, value) ⇒ Boolean
Methods inherited from BasicType
#of, #to_s, #totally_valid?, #|
Constructor Details
#initialize(schema_name, options = {}) ⇒ SchemaIdType
Returns a new instance of SchemaIdType.
4 5 6 7 |
# File 'lib/restspec/schema/types/schema_id_type.rb', line 4 def initialize(schema_name, = {}) self.schema_name = schema_name super() 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 |