Class: Satchel::Activity
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Satchel::Activity
- Defined in:
- app/models/satchel/activity.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(data) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/models/satchel/activity.rb', line 4 def self.call(data) create! do |activity| activity.subject = data.subject activity.user = data.current_user activity. = data. activity.activity_type = data.activity_type end end |
Instance Method Details
#subject ⇒ Object
15 16 17 |
# File 'app/models/satchel/activity.rb', line 15 def subject subject_type.constantize.find(subject_id) end |
#subject=(object) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/models/satchel/activity.rb', line 19 def subject=(object) if object.persisted? write_attribute(:subject_type, object.class.to_s) write_attribute(:subject_id, object.to_param) else raise UnpersistedSubjectError.new(object) end end |