Class: ActionTracker::Models::Payload
Constant Summary
collapse
- MAX_CONTENT_LENGTH =
1000
Instance Method Summary
collapse
infer_model_name, mimic, mimicked_model_name, model_name, #model_name, #present_attributes, #to_key
Instance Method Details
#attributes ⇒ Object
38
39
40
|
# File 'lib/action_tracker/models/payload.rb', line 38
def attributes
super.merge(user: user.attributes)
end
|
#for_event(event) ⇒ Object
28
29
30
31
|
# File 'lib/action_tracker/models/payload.rb', line 28
def for_event(event)
self[:event] = event.to_s.humanize
self
end
|
#with_content(content) ⇒ Object
33
34
35
36
|
# File 'lib/action_tracker/models/payload.rb', line 33
def with_content(content)
self[:content] = content.to_s.truncate(MAX_CONTENT_LENGTH)
self
end
|
#with_user(user) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/action_tracker/models/payload.rb', line 14
def with_user(user)
self[:user] = ActionTracker::Models::User.new(
id: user.try(:id),
name: user.try(:name),
type: user.try(:type)
)
self
end
|