Class: Syncify::Association::StandardAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/syncify/association/standard_association.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_class:, association:, destination:) ⇒ StandardAssociation

Returns a new instance of StandardAssociation.



6
7
8
9
10
11
12
# File 'lib/syncify/association/standard_association.rb', line 6

def initialize(from_class:, association:, destination:)
  @from_class = from_class
  @to_class = association.klass
  @name = association.name
  @destination = destination
  @traversed = false
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



4
5
6
# File 'lib/syncify/association/standard_association.rb', line 4

def destination
  @destination
end

#from_classObject

Returns the value of attribute from_class.



4
5
6
# File 'lib/syncify/association/standard_association.rb', line 4

def from_class
  @from_class
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/syncify/association/standard_association.rb', line 4

def name
  @name
end

#to_classObject

Returns the value of attribute to_class.



4
5
6
# File 'lib/syncify/association/standard_association.rb', line 4

def to_class
  @to_class
end

#traversedObject

Returns the value of attribute traversed.



4
5
6
# File 'lib/syncify/association/standard_association.rb', line 4

def traversed
  @traversed
end

Instance Method Details

#create_destination(name) ⇒ Object



30
31
32
# File 'lib/syncify/association/standard_association.rb', line 30

def create_destination(name)
  destination[name] = {}
end

#eql?(other_association) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/syncify/association/standard_association.rb', line 38

def eql?(other_association)
  self.from_class == other_association.from_class &&
    self.to_class == other_association.to_class &&
    self.name == other_association.name
end

#hashObject



34
35
36
# File 'lib/syncify/association/standard_association.rb', line 34

def hash
  "#{self.from_class.to_s}#{self.to_class.to_s}#{self.name}".hash
end

#inverse_of?(association) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/syncify/association/standard_association.rb', line 22

def inverse_of?(association)
  if association.polymorphic?
    association.to_classes.include?(from_class) && association.from_class == to_class
  else
    association.to_class == from_class && association.from_class == to_class
  end
end

#polymorphic?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/syncify/association/standard_association.rb', line 14

def polymorphic?
  false
end

#traversed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/syncify/association/standard_association.rb', line 18

def traversed?
  traversed
end