Class: Organizations::CallbackContext
- Inherits:
-
Struct
- Object
- Struct
- Organizations::CallbackContext
- Defined in:
- lib/organizations/callback_context.rb
Overview
Immutable context object passed to all callbacks. Provides consistent, typed access to event data.
Different events populate different fields:
- :organization_created => organization, user
- :member_invited => organization, invitation, invited_by
- :member_joined => organization, membership, user
- :member_removed => organization, membership, user, removed_by
- :role_changed => organization, membership, old_role, new_role, changed_by
- :ownership_transferred => organization, old_owner, new_owner
- :member_joining => organization, user, role, joined_via, invitation/join_request (whichever instrument applies) (STRICT + pre-persist: raise Organizations::MembershipVetoed to veto — see Configuration#on_member_joining)
- :join_request_created => organization, user, join_request
- :join_request_approved => organization, user, join_request, membership, decided_by (nil for auto-approvals)
- :join_request_rejected => organization, user, join_request, decided_by
Instance Attribute Summary collapse
-
#changed_by ⇒ Object
Returns the value of attribute changed_by.
-
#decided_by ⇒ Object
Returns the value of attribute decided_by.
-
#event ⇒ Object
Returns the value of attribute event.
-
#invitation ⇒ Object
Returns the value of attribute invitation.
-
#invited_by ⇒ Object
Returns the value of attribute invited_by.
-
#join_request ⇒ Object
Returns the value of attribute join_request.
-
#joined_via ⇒ Object
Returns the value of attribute joined_via.
-
#membership ⇒ Object
Returns the value of attribute membership.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#new_owner ⇒ Object
Returns the value of attribute new_owner.
-
#new_role ⇒ Object
Returns the value of attribute new_role.
-
#old_owner ⇒ Object
Returns the value of attribute old_owner.
-
#old_role ⇒ Object
Returns the value of attribute old_role.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#permission ⇒ Object
Returns the value of attribute permission.
-
#removed_by ⇒ Object
Returns the value of attribute removed_by.
-
#required_role ⇒ Object
Returns the value of attribute required_role.
-
#role ⇒ Object
Returns the value of attribute role.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#event?(event_name) ⇒ Boolean
Check if this is a specific event type.
-
#to_h ⇒ Hash
Convert to hash, removing nil values.
Instance Attribute Details
#changed_by ⇒ Object
Returns the value of attribute changed_by
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def changed_by @changed_by end |
#decided_by ⇒ Object
Returns the value of attribute decided_by
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def decided_by @decided_by end |
#event ⇒ Object
Returns the value of attribute event
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def event @event end |
#invitation ⇒ Object
Returns the value of attribute invitation
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def invitation @invitation end |
#invited_by ⇒ Object
Returns the value of attribute invited_by
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def invited_by @invited_by end |
#join_request ⇒ Object
Returns the value of attribute join_request
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def join_request @join_request end |
#joined_via ⇒ Object
Returns the value of attribute joined_via
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def joined_via @joined_via end |
#membership ⇒ Object
Returns the value of attribute membership
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def membership @membership end |
#metadata ⇒ Object
Returns the value of attribute metadata
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def @metadata end |
#new_owner ⇒ Object
Returns the value of attribute new_owner
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def new_owner @new_owner end |
#new_role ⇒ Object
Returns the value of attribute new_role
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def new_role @new_role end |
#old_owner ⇒ Object
Returns the value of attribute old_owner
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def old_owner @old_owner end |
#old_role ⇒ Object
Returns the value of attribute old_role
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def old_role @old_role end |
#organization ⇒ Object
Returns the value of attribute organization
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def organization @organization end |
#permission ⇒ Object
Returns the value of attribute permission
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def @permission end |
#removed_by ⇒ Object
Returns the value of attribute removed_by
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def removed_by @removed_by end |
#required_role ⇒ Object
Returns the value of attribute required_role
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def required_role @required_role end |
#role ⇒ Object
Returns the value of attribute role
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def role @role end |
#user ⇒ Object
Returns the value of attribute user
25 26 27 |
# File 'lib/organizations/callback_context.rb', line 25 def user @user end |
Instance Method Details
#event?(event_name) ⇒ Boolean
Check if this is a specific event type
56 57 58 |
# File 'lib/organizations/callback_context.rb', line 56 def event?(event_name) event == event_name end |
#to_h ⇒ Hash
Convert to hash, removing nil values
49 50 51 |
# File 'lib/organizations/callback_context.rb', line 49 def to_h super.compact end |