Sha256: 8dfdcf54ad9ab76e3290fd5a66609868c53ba719953e8c935408336a44537f3c

Contents?: true

Size: 681 Bytes

Versions: 6

Compression:

Stored size: 681 Bytes

Contents

module Product::ProjectManagement
  extend ActiveSupport::Concern 
  
  included do
    has_many :stories, dependent: :nullify
  end
  
  module ClassMethods
    def stories(id, user)
      collection = if id == 'no-name'
        Story.exists(_type: false)
      else
        product = Product.find(id)
        
        begin
          product.story_class.for_user(user)
        rescue NotImplementedError
          product.story_class
        end
      end
      
      collection.where(:users_without_tasks_ids.ne => user.id)
    end
  end
    
  def projects; Project.where(product_id: id); end
  
  def story_class; "#{self.class.name}::Story".constantize rescue Story; end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voluntary-0.2.4 app/models/product/project_management.rb
voluntary-0.2.3 app/models/product/project_management.rb
voluntary-0.2.2 app/models/product/project_management.rb
voluntary-0.2.1 app/models/product/project_management.rb
voluntary-0.2.0 app/models/product/project_management.rb
voluntary-0.1.0 app/models/product/project_management.rb