Class: Familia::Features::Relationships::ParticipationMembership

Inherits:
Data
  • Object
show all
Defined in:
lib/familia/features/relationships/participation_membership.rb

Overview

Note:

This represents what currently exists in Redis, not just configuration. See ParticipationRelationship for static configuration metadata.

ParticipationMembership

Represents runtime snapshot of a participant's membership in a target collection. Returned by current_participations to provide a type-safe, structured view of actual participation state.

Examples:

membership = user.current_participations.first
membership.target_class  # => "Team"
membership.target_id     # => "team123"
membership.collection_name  # => :members
membership.type          # => :sorted_set
membership.score         # => 1762554020.05

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collection_nameObject (readonly)

Returns the value of attribute collection_name

Returns:

  • (Object)

    the current value of collection_name



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def collection_name
  @collection_name
end

#decoded_scoreObject (readonly)

Returns the value of attribute decoded_score

Returns:

  • (Object)

    the current value of decoded_score



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def decoded_score
  @decoded_score
end

#positionObject (readonly)

Returns the value of attribute position

Returns:

  • (Object)

    the current value of position



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def position
  @position
end

#scoreObject (readonly)

Returns the value of attribute score

Returns:

  • (Object)

    the current value of score



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def score
  @score
end

#target_classObject (readonly)

Returns the value of attribute target_class

Returns:

  • (Object)

    the current value of target_class



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def target_class
  @target_class
end

#target_idObject (readonly)

Returns the value of attribute target_id

Returns:

  • (Object)

    the current value of target_id



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def target_id
  @target_id
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



26
27
28
# File 'lib/familia/features/relationships/participation_membership.rb', line 26

def type
  @type
end

Instance Method Details

#list?Boolean

Check if this membership is a list

Returns:

  • (Boolean)


49
50
51
# File 'lib/familia/features/relationships/participation_membership.rb', line 49

def list?
  type == :list
end

#set?Boolean

Check if this membership is a set

Returns:

  • (Boolean)


43
44
45
# File 'lib/familia/features/relationships/participation_membership.rb', line 43

def set?
  type == :set
end

#sorted_set?Boolean

Check if this membership is a sorted set

Returns:

  • (Boolean)


37
38
39
# File 'lib/familia/features/relationships/participation_membership.rb', line 37

def sorted_set?
  type == :sorted_set
end

#target_instanceFamilia::Horreum?

Get the target instance (requires loading from database)

Returns:



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/familia/features/relationships/participation_membership.rb', line 55

def target_instance
  return nil unless target_class

  # Resolve class from string name
  # Only rescue NameError (class doesn't exist), not all exceptions
  klass = Object.const_get(target_class)
  klass.find_by_id(target_id)
rescue NameError
  # Target class doesn't exist or isn't loaded
  nil
end