class ActionTracker::Templates::BaseTemplate
Attributes
options[R]
target[R]
Public Class Methods
new(target, options = {})
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 8 def initialize(target, options = {}) @target = target @options = options end
Public Instance Methods
form()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 13 def form @form ||= ActionTracker::Models::TransitionRecord.new( payload: payload, reference: reference, created_at: created_at ).with_target(target) end
Protected Instance Methods
build_payload()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 27 def build_payload payload_instance = ActionTracker::Models::Payload.new payload_instance .with_user(user) .with_content(content) .for_event(event_title) end
content()
click to toggle source
Override
# File lib/action_tracker/templates/base_template.rb, line 42 def content options[:content] || target.try(:id) end
created_at()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 62 def created_at options[:created_at] || Time.zone&.now end
event_name()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 50 def event_name # Override end
event_title()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 46 def event_title [title_prepend, event_name, title_append].compact.join(' ').humanize end
payload()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 23 def payload @payload ||= build_payload end
reference()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 66 def reference options[:reference] end
title_append()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 58 def title_append options[:title_append] end
title_prepend()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 54 def title_prepend options[:title_prepend] end
user()
click to toggle source
# File lib/action_tracker/templates/base_template.rb, line 36 def user @user ||= options[:user] || ActionTracker::Models::User.default_user end