Class: JSONAPIonify::Structure::Objects::ResourceIdentifier
- Defined in:
- lib/jsonapionify/structure/objects/resource_identifier.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#errors, #object, #parent, #warnings
Instance Method Summary collapse
- #==(other) ⇒ Object
- #duplicate_does_not_exist? ⇒ Boolean
- #duplicate_exists? ⇒ Boolean
- #same_as?(other) ⇒ Boolean
Methods inherited from Base
#===, #as_json, #compile, #compile!, #copy, define_order, from_hash, from_json, #initialize, #pretty_json, #signature, #to_h, #to_json, #validate
Methods included from Helpers::ObjectDefaults
Methods included from Helpers::Validations
#allowed_type_map, #permitted_key?, #permitted_keys, #permitted_type_for?, #permitted_types_for, #required_key?, #required_keys
Methods included from Helpers::ObjectSetters
Methods included from Helpers::InheritsOrigin
Methods included from Callbacks
Constructor Details
This class inherits a constructor from JSONAPIonify::Structure::Objects::Base
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 29 def ==(other) same_as? other end |
#duplicate_does_not_exist? ⇒ Boolean
33 34 35 |
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 33 def duplicate_does_not_exist? !duplicate_exists? end |
#duplicate_exists? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 23 def duplicate_exists? return false unless parent.is_a?(Array) peers = parent - [self] !!peers.index(self) end |
#same_as?(other) ⇒ Boolean
37 38 39 40 41 42 43 44 |
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 37 def same_as?(other) return false unless other.is_a? ResourceIdentifier other_type, other_id = other.values_at :type, :id local_type, local_id = values_at :type, :id other_type == local_type && !(other_id || local_id).nil? && other_id == local_id end |