Class: Product
- Inherits:
-
Object
- Object
- Product
- Includes:
- ActiveModel::MassAssignmentSecurity, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/product.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ProjectManagement Classes: MusicMetadataEnrichment, NewProduct
Class Method Summary collapse
-
.reflections ⇒ Object
active record compatibility just belongs_to reflections for cucumber’s factory steps.
- .stories(id, user) ⇒ Object
Instance Method Summary collapse
-
#areas ⇒ Object
has_many (SQL).
- #projects ⇒ Object
- #stories_for_user(user) ⇒ Object
-
#user ⇒ Object
belongs_to (SQL).
- #user=(value) ⇒ Object
Class Method Details
.reflections ⇒ Object
active record compatibility just belongs_to reflections for cucumber’s factory steps
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/product.rb', line 24 def self.reflections struct = OpenStruct.new(values: []) # sql belongs_to relations struct.values << OpenStruct.new(name: 'user', options: {}) ::Product.relations.each do |relation_name, relation| # select only belongs_to relations next unless relation_name == relation_name.singularize # automatically include mongo db's belongs_to relations struct.values << OpenStruct.new(name: relation_name, options: {}) end struct end |
.stories(id, user) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/product.rb', line 41 def self.stories(id, user) collection = if id == 'no-name' Story.where(_type: 'Story') 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 |
Instance Method Details
#areas ⇒ Object
has_many (SQL)
66 |
# File 'app/models/product.rb', line 66 def areas; Area.where(id: area_ids); end |
#projects ⇒ Object
67 |
# File 'app/models/product.rb', line 67 def projects; Project.where(product_id: id); end |
#stories_for_user(user) ⇒ Object
57 58 59 |
# File 'app/models/product.rb', line 57 def stories_for_user(user) self.class.stories(id, user) end |
#user ⇒ Object
belongs_to (SQL)
62 |
# File 'app/models/product.rb', line 62 def user; User.find(offeror_id); end |
#user=(value) ⇒ Object
63 |
# File 'app/models/product.rb', line 63 def user=(value); self.user_id = value.id; end |