Class: PandaCms::Admin::UserActivityComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- PandaCms::Admin::UserActivityComponent
- Defined in:
- app/components/panda_cms/admin/user_activity_component.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#time ⇒ Object
Returns the value of attribute time.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(whodunnit_to: nil, at: nil, user: nil) ⇒ UserActivityComponent
constructor
A new instance of UserActivityComponent.
Constructor Details
#initialize(whodunnit_to: nil, at: nil, user: nil) ⇒ UserActivityComponent
Returns a new instance of UserActivityComponent.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/panda_cms/admin/user_activity_component.rb', line 11 def initialize(whodunnit_to: nil, at: nil, user: nil) if whodunnit_to @model = whodunnit_to whodunnit_id = @model.versions&.last&.whodunnit if whodunnit_id @user = User.find(whodunnit_id) @time = @model.updated_at end elsif user.is_a?(::PandaCms::User) && at.is_a?(::ActiveSupport::TimeWithZone) @user = user @time = at end if !@time @user = nil @time = nil end end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
6 7 8 |
# File 'app/components/panda_cms/admin/user_activity_component.rb', line 6 def model @model end |
#time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'app/components/panda_cms/admin/user_activity_component.rb', line 7 def time @time end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'app/components/panda_cms/admin/user_activity_component.rb', line 8 def user @user end |