Class: FunWithJsonApi::SchemaValidators::CheckCollectionHasAllMembers
- Inherits:
-
Object
- Object
- FunWithJsonApi::SchemaValidators::CheckCollectionHasAllMembers
- Defined in:
- lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#deserializer ⇒ Object
readonly
Returns the value of attribute deserializer.
-
#document_ids ⇒ Object
readonly
Returns the value of attribute document_ids.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(collection, document_ids, deserializer, prefix: '/data') ⇒ CheckCollectionHasAllMembers
constructor
A new instance of CheckCollectionHasAllMembers.
- #resource_type ⇒ Object
Constructor Details
#initialize(collection, document_ids, deserializer, prefix: '/data') ⇒ CheckCollectionHasAllMembers
Returns a new instance of CheckCollectionHasAllMembers.
17 18 19 20 21 22 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 17 def initialize(collection, document_ids, deserializer, prefix: '/data') @collection = collection @document_ids = document_ids @deserializer = deserializer @prefix = prefix end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
10 11 12 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 10 def collection @collection end |
#deserializer ⇒ Object (readonly)
Returns the value of attribute deserializer.
12 13 14 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 12 def deserializer @deserializer end |
#document_ids ⇒ Object (readonly)
Returns the value of attribute document_ids.
11 12 13 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 11 def document_ids @document_ids end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
13 14 15 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 13 def prefix @prefix end |
Class Method Details
.call ⇒ Object
6 7 8 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 6 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 24 def call if collection.size != document_ids.size collection_ids = deserializer.format_collection_ids(collection) raise build_missing_resources_error(collection_ids) end end |
#resource_type ⇒ Object
31 32 33 |
# File 'lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb', line 31 def resource_type deserializer.type end |