Class: Study
- Defined in:
- lib/tmis/engine/models/study.rb
Overview
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Class Method Summary collapse
-
.of_group_and_its_subgroups(group) ⇒ Object
Contract Group => ActiveRecord::Relation.
-
.of_groups_and_its_subgroups(groups) ⇒ Object
Use Model#scoped instead of Model#all Contract ActiveRecord::Relation => ActiveRecord::Relation::ActiveRecord_Relation_Group.
Instance Method Summary collapse
Class Method Details
.of_group_and_its_subgroups(group) ⇒ Object
Contract Group => ActiveRecord::Relation
19 20 21 |
# File 'lib/tmis/engine/models/study.rb', line 19 def self.of_group_and_its_subgroups(group) where_groups_or_subgroups(group.id, Subgroup.where(group_id: group.id)) end |
.of_groups_and_its_subgroups(groups) ⇒ Object
Use Model#scoped instead of Model#all Contract ActiveRecord::Relation => ActiveRecord::Relation::ActiveRecord_Relation_Group
14 15 16 |
# File 'lib/tmis/engine/models/study.rb', line 14 def self.of_groups_and_its_subgroups(groups) where_groups_or_subgroups(groups.select(:id), Subgroup.where(group_id: groups.select(:id))) end |
Instance Method Details
#get_group ⇒ Object
26 27 28 |
# File 'lib/tmis/engine/models/study.rb', line 26 def get_group groupable.get_group end |
#to_group? ⇒ Boolean
30 31 32 |
# File 'lib/tmis/engine/models/study.rb', line 30 def to_group? groupable_type == 'Group' end |
#to_s ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tmis/engine/models/study.rb', line 38 def to_s begin if to_subgroup? "#{subject.title}\n#{lecturer}" + " (#{groupable.number}п)" else "#{subject.title}\n#{lecturer}" end rescue #FIXME 'ERROR' end end |
#to_subgroup? ⇒ Boolean
34 35 36 |
# File 'lib/tmis/engine/models/study.rb', line 34 def to_subgroup? groupable_type == 'Subgroup' end |
#validate ⇒ Object
23 24 |
# File 'lib/tmis/engine/models/study.rb', line 23 def validate end |