Class: Project

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/project.rb

Constant Summary collapse

PARENT_TYPES =
['area', 'product', 'user', 'organization']

Instance Method Summary collapse

Instance Method Details

#productObject

belongs_to (Mongo DB)



39
40
41
42
43
# File 'app/models/project.rb', line 39

def product
  return @product if @product
  
  @product = product_id.blank? ? nil : Product.find(product_id)
end

#product=(document) ⇒ Object



45
46
47
48
# File 'app/models/project.rb', line 45

def product=(document)
  @product = document
  self.product_id = @product.try(:id)
end

#storiesObject



59
# File 'app/models/project.rb', line 59

def stories; story_class.where(project_id: id); end

#story_classObject

has_many (Mongo DB)



51
52
53
54
55
56
57
# File 'app/models/project.rb', line 51

def story_class
  if product_id.present?
    "#{product.class.name}::Story".constantize rescue Story
  else
    Story
  end
end