Class: Syncify::Association::StandardAssociation
- Inherits:
-
Object
- Object
- Syncify::Association::StandardAssociation
- Defined in:
- lib/syncify/association/standard_association.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#from_class ⇒ Object
Returns the value of attribute from_class.
-
#name ⇒ Object
Returns the value of attribute name.
-
#to_class ⇒ Object
Returns the value of attribute to_class.
-
#traversed ⇒ Object
Returns the value of attribute traversed.
Instance Method Summary collapse
- #create_destination(name) ⇒ Object
- #eql?(other_association) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(from_class:, association:, destination:) ⇒ StandardAssociation
constructor
A new instance of StandardAssociation.
- #inverse_of?(association) ⇒ Boolean
- #polymorphic? ⇒ Boolean
- #traversed? ⇒ Boolean
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
#destination ⇒ Object
Returns the value of attribute destination.
4 5 6 |
# File 'lib/syncify/association/standard_association.rb', line 4 def destination @destination end |
#from_class ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/syncify/association/standard_association.rb', line 4 def name @name end |
#to_class ⇒ Object
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 |
#traversed ⇒ Object
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
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 |
#hash ⇒ Object
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
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
14 15 16 |
# File 'lib/syncify/association/standard_association.rb', line 14 def polymorphic? false end |
#traversed? ⇒ Boolean
18 19 20 |
# File 'lib/syncify/association/standard_association.rb', line 18 def traversed? traversed end |