Sha256: 56dfbd996e9fbc704bd95882b1e2936a11647f13a4f74246262243d5c74e2b56
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module Tasuku module Concerns::Models::Requirables::Requirable extend ActiveSupport::Concern included do has_many :task_requirements has_many :requirements, through: :task_requirements has_many :inverse_tasks, class_name: "TaskRequirement", foreign_key: :requirement_id has_many :required_for, through: :inverse_tasks, source: :task accepts_nested_attributes_for :requirements, allow_destroy: true def locked? author required_task_ids = self.task_requirements.pluck :requirement_id return false if required_task_ids.empty? completed_task_ids = Tasuku::Task.completed_by(author). where('tasuku_taskables_taskable_responses.task_id IN (?)', required_task_ids) completed_task_ids.length.eql?(required_task_ids.length) ? false : true end def locked_by_tasks author completed_task_ids = Tasuku::Task.completed_by(author).pluck(:id) || [] scope = self.requirements scope = scope.where( 'tasuku_task_requirements.requirement_id NOT IN (?)', completed_task_ids ) unless completed_task_ids.empty? scope end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tasuku-1.1.0 | lib/tasuku/concerns/models/requirables/requirable.rb |
tasuku-1.0.1 | lib/tasuku/concerns/models/requirables/requirable.rb |