Module: Activityko::ViewHelpers
- Defined in:
- lib/activityko/view_helpers.rb
Instance Method Summary collapse
- #activity_action ⇒ Object
- #activity_dir_obj ⇒ Object
- #activity_prep ⇒ Object
- #activity_prep_obj ⇒ Object
- #activity_subj ⇒ Object
- #activity_time ⇒ Object
- #basic_activity(activity) ⇒ Object
- #render_activity(activity) ⇒ Object
Instance Method Details
#activity_action ⇒ Object
30 31 32 |
# File 'lib/activityko/view_helpers.rb', line 30 def activity_action @activityko_instance.action.humanize.downcase end |
#activity_dir_obj ⇒ Object
22 23 24 25 |
# File 'lib/activityko/view_helpers.rb', line 22 def activity_dir_obj dir_obj = @activityko_instance.dir_obj link_to dir_obj.activity_name, dir_obj end |
#activity_prep ⇒ Object
33 34 35 |
# File 'lib/activityko/view_helpers.rb', line 33 def activity_prep @activityko_instance.prep.humanize.downcase end |
#activity_prep_obj ⇒ Object
36 37 38 39 |
# File 'lib/activityko/view_helpers.rb', line 36 def activity_prep_obj prep_obj = @activityko_instance.prep_obj link_to prep_obj.activity_name, prep_obj end |
#activity_subj ⇒ Object
26 27 28 29 |
# File 'lib/activityko/view_helpers.rb', line 26 def activity_subj subj = @activityko_instance.subj link_to(subj.activity_name, subj) end |
#activity_time ⇒ Object
40 41 42 |
# File 'lib/activityko/view_helpers.rb', line 40 def activity_time time_ago_in_words @activityko_instance.created_at end |
#basic_activity(activity) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/activityko/view_helpers.rb', line 8 def basic_activity activity @activityko_instance = activity if block_given? yield else sentence = [] sentence << activity_subj if activity.subj sentence << activity_action sentence << activity_dir_obj if activity.dir_obj sentence << activity_prep if activity.prep sentence << activity_prep_obj if activity.prep_obj return sentence.join(" ").html_safe end end |
#render_activity(activity) ⇒ Object
4 5 6 7 |
# File 'lib/activityko/view_helpers.rb', line 4 def render_activity activity render partial: "activities/#{activity.dir_obj_type.downcase}/#{activity.action}", locals: { activity: activity } rescue basic_activity(activity) end |