Class: Relation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Relation
- Defined in:
- app/models/relation.rb
Overview
A Relation defines a type of Tie. Relations are affective (friendship, liking, respect), formal or biological (authority, kinship), transfer of material resources (transactions, lending and borrowing), messages or conversations, physical connection and affiliation to same organizations.
Strength hierarchies
Relations are arranged in strength hierarchies, denoting that some ties between two actors are stronger than others. When a strong tie is established, ties with weaker relations are establised as well
Reflexive relations
Some relations are set by default for actors with theirselves. This sets some ties for posting in self wall at several visibility levels: only for friends, public and so on
Inverse relations
A Relation can have its inverse. When a tie is established, an inverse tie will be established if an inverse relation exists. An example is a relation of friendship, whose inverse relation is itself. When A is friend of B, the inverse tie B is friend of A is establised as well.
Granted relations
There are cases when relations need previous invitation or request to be granted. This is the case of friendship requests. When A wants to become friend of B, A sends a friendship_request to B. A is granting the friend relation with B, that is, friendship_request grants friend relation.
Active relations
Those relations whose ties support activities. The default scope define active relations as those that do not grant other relations, those that are not invitations or requests.
Class Method Summary collapse
-
.strongest ⇒ Object
A relation in the top of a strength hierarchy.
Instance Method Summary collapse
-
#mode ⇒ Object
Relation class scoped in the same mode that this relation.
-
#stronger ⇒ Object
Other relations above in the same hierarchy that this relation.
-
#stronger_or_equal ⇒ Object
Relations above or at the same level of this relation.
-
#weaker ⇒ Object
Other relations below in the same hierarchy that this relation.
-
#weaker_or_equal ⇒ Object
Relations below or at the same level of this relation.
Class Method Details
.strongest ⇒ Object
A relation in the top of a strength hierarchy
56 57 58 |
# File 'app/models/relation.rb', line 56 def strongest roots.first end |
Instance Method Details
#mode ⇒ Object
Relation class scoped in the same mode that this relation
82 83 84 |
# File 'app/models/relation.rb', line 82 def mode Relation.mode(sender_type, receiver_type) end |
#stronger ⇒ Object
Other relations above in the same hierarchy that this relation
72 73 74 |
# File 'app/models/relation.rb', line 72 def stronger ancestors end |
#stronger_or_equal ⇒ Object
Relations above or at the same level of this relation
77 78 79 |
# File 'app/models/relation.rb', line 77 def stronger_or_equal ancestors + Array(self) end |
#weaker ⇒ Object
Other relations below in the same hierarchy that this relation
62 63 64 |
# File 'app/models/relation.rb', line 62 def weaker descendants end |
#weaker_or_equal ⇒ Object
Relations below or at the same level of this relation
67 68 69 |
# File 'app/models/relation.rb', line 67 def weaker_or_equal Array(self) + descendants end |