Class: JSONAPIonify::Structure::Objects::ResourceIdentifier

Inherits:
Base
  • Object
show all
Defined in:
lib/jsonapionify/structure/objects/resource_identifier.rb

Direct Known Subclasses

Resource

Instance Attribute Summary

Attributes inherited from Base

#errors, #object, #parent, #warnings

Instance Method Summary collapse

Methods inherited from Base

#==, #===, #as_json, #compile, #compile!, #copy, define_order, from_hash, from_json, #initialize, #inspect, #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

#client?, #origin, #server?

Methods included from Callbacks

#run_callbacks

Constructor Details

This class inherits a constructor from JSONAPIonify::Structure::Objects::Base

Instance Method Details

#duplicate_does_not_exist?Boolean

Returns:



29
30
31
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 29

def duplicate_does_not_exist?
  !duplicate_exists?
end

#duplicate_exists?Boolean

Returns:



24
25
26
27
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 24

def duplicate_exists?
  return false unless parent.is_a?(Array)
  parent.select { |peer| peer.eql? self }.length > 1
end

#eql?(other) ⇒ Boolean

Returns:



37
38
39
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 37

def eql?(other)
  other.hash == self.hash
end

#hashObject



33
34
35
# File 'lib/jsonapionify/structure/objects/resource_identifier.rb', line 33

def hash
  { type: self[:type], id: self[:id] }.hash
end