Sha256: b5ecf96dc6484892ba3ab781844c463c7aa846e66fb1fddfdcff1880ca4705d3
Contents?: true
Size: 847 Bytes
Versions: 4
Compression:
Stored size: 847 Bytes
Contents
module Tasuku module Taskables::Taskable extend ActiveSupport::Concern # Determine whether the task has been completed by the given author. # # author - Any model that can complete tasks. # # Returns a Boolean. def completed_by? author !!responses.find_by(author: author) end included do has_one :task, as: :taskable, class_name: '::Tasuku::Task', dependent: :destroy end module ClassMethods # Declare the relation for responses. # # are - A model that represents submissions. # # This method really only aliases the name of the taskable's join model # between authors and tasks to 'responses' so as to promote a common interface # for any taskable. def responses are: nil alias_method :responses, are end end end end
Version data entries
4 entries across 4 versions & 1 rubygems