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: 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).
- #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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/product.rb', line 27 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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/product.rb', line 44 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)
69 |
# File 'app/models/product.rb', line 69 def areas; Area.where(id: area_ids); end |
#stories_for_user(user) ⇒ Object
60 61 62 |
# File 'app/models/product.rb', line 60 def stories_for_user(user) self.class.stories(id, user) end |
#user ⇒ Object
belongs_to (SQL)
65 |
# File 'app/models/product.rb', line 65 def user; User.find(offeror_id); end |
#user=(value) ⇒ Object
66 |
# File 'app/models/product.rb', line 66 def user=(value); self.user_id = value.id; end |