Class: SocialNetworking::Goal
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SocialNetworking::Goal
- Defined in:
- app/models/social_networking/goal.rb
Overview
Something to be completed by a Participant.
Constant Summary collapse
- ACTION_TYPES =
create a mini DSL for types of Goal actions
%w( created completed did_not_complete ).freeze
- Actions =
Struct.new(*ACTION_TYPES.map(&:to_sym)) .new(*(ACTION_TYPES.map { |t| t.tr("_", " ") }))
Instance Method Summary collapse
-
#action ⇒ Object
rubocop:enable Style/PredicateName.
-
#is_completed ⇒ Object
Necessary for legacy front-end code.
-
#is_deleted ⇒ Object
Necessary for legacy front-end code.
- #shared_description ⇒ Object
- #to_serialized ⇒ Object
Instance Method Details
#action ⇒ Object
rubocop:enable Style/PredicateName
54 55 56 57 58 59 60 61 62 |
# File 'app/models/social_networking/goal.rb', line 54 def action if is_completed "Completed" elsif due_on && due_on < Time.zone.today "Did Not Complete" else "Created" end end |
#is_completed ⇒ Object
Necessary for legacy front-end code. rubocop:disable Style/PredicateName
42 43 44 |
# File 'app/models/social_networking/goal.rb', line 42 def is_completed completed_at? end |
#is_deleted ⇒ Object
Necessary for legacy front-end code. rubocop:disable Style/PredicateName
49 50 51 |
# File 'app/models/social_networking/goal.rb', line 49 def is_deleted deleted_at? end |
#shared_description ⇒ Object
36 37 38 |
# File 'app/models/social_networking/goal.rb', line 36 def shared_description "Goal: #{description}" end |
#to_serialized ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/social_networking/goal.rb', line 25 def to_serialized if due_on { description: description, dueOn: due_on.to_s(:participant_date) } else {} end end |