Class: Integral::VersionDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- Integral::VersionDecorator
- Defined in:
- app/decorators/integral/version_decorator.rb
Overview
Page view-level logic
Instance Method Summary collapse
-
#attributes_changed ⇒ String
Formatted attributes changed.
-
#decorated_item ⇒ Object
Associated Item.
-
#event ⇒ String
Formatted event.
-
#item_title ⇒ String
Formatted title.
-
#item_type ⇒ String
Formatted item type.
-
#item_url ⇒ String
Item URL.
-
#url ⇒ String
URL to view version screen.
-
#whodunnit ⇒ Integral::User
Who carried out the version (if one exists).
Instance Method Details
#attributes_changed ⇒ String
Returns formatted attributes changed.
46 47 48 49 50 51 52 53 54 55 |
# File 'app/decorators/integral/version_decorator.rb', line 46 def attributes_changed return unless object.event == 'update' keys = '' object.changeset.each_key do |key| # next if ['updated_at', 'lock_version'].include? key keys += "#{key}, " end keys[0..-3] end |
#decorated_item ⇒ Object
Returns Associated Item.
36 37 38 |
# File 'app/decorators/integral/version_decorator.rb', line 36 def decorated_item @decorated_item ||= item&.decorate end |
#event ⇒ String
Returns formatted event.
12 13 14 |
# File 'app/decorators/integral/version_decorator.rb', line 12 def event h.t("integral.actions.#{object.event}") end |
#item_title ⇒ String
Returns formatted title.
31 32 33 |
# File 'app/decorators/integral/version_decorator.rb', line 31 def item_title decorated_item&.title end |
#item_type ⇒ String
Returns formatted item type.
41 42 43 |
# File 'app/decorators/integral/version_decorator.rb', line 41 def item_type object.item_type.constantize.model_name.human end |
#item_url ⇒ String
Returns Item URL.
17 18 19 |
# File 'app/decorators/integral/version_decorator.rb', line 17 def item_url decorated_item&.backend_url end |
#url ⇒ String
Returns URL to view version screen.
7 8 9 |
# File 'app/decorators/integral/version_decorator.rb', line 7 def url decorated_item&.activity_url(object.id) end |
#whodunnit ⇒ Integral::User
Returns who carried out the version (if one exists).
22 23 24 25 26 27 28 |
# File 'app/decorators/integral/version_decorator.rb', line 22 def whodunnit user_id = object.whodunnit.to_i return '' if user_id.zero? @user = Integral::User.unscoped.find_by_id(object.whodunnit)&.decorate end |