|
1 | 1 | require_dependency 'projects_helper'
|
2 | 2 |
|
3 | 3 | module ProjectTree
|
4 |
| - module Patches |
5 |
| - module ProjectsHelperPatch |
6 |
| - |
7 |
| - def top_projects |
8 |
| - @top_projects ||= find_toplevel_projects |
9 |
| - end |
10 |
| - |
11 |
| - |
12 |
| - def self.included(base) # :nodoc: |
13 |
| - base.send(:include, InstanceMethods) |
| 4 | + module Patches |
| 5 | + module ProjectsHelperPatch |
| 6 | + |
| 7 | + def top_projects |
| 8 | + @top_projects ||= find_toplevel_projects |
| 9 | + end |
| 10 | + |
| 11 | + |
| 12 | + def self.included(base) # :nodoc: |
| 13 | + base.send(:include, InstanceMethods) |
14 | 14 |
|
15 |
| - #base.class_eval do |
16 |
| - # 'unloadable' -> This is required only in the development mode |
17 |
| - # unloadable |
18 |
| - |
19 |
| - # chain definition about new method which overrides to old method (see below: 'new_method_with_old_method') |
20 |
| - #alias_method_chain :new_method, :old_method |
| 15 | + #base.class_eval do |
| 16 | + # 'unloadable' -> This is required only in the development mode |
| 17 | + # unloadable |
| 18 | + |
| 19 | + # chain definition about new method which overrides to old method (see below: 'new_method_with_old_method') |
| 20 | + #alias_method_chain :new_method, :old_method |
21 | 21 |
|
22 |
| - # Anything you type in here is just like typing directly in the core |
23 |
| - # source files and will be run when the controller class is loaded. |
24 |
| - end |
| 22 | + # Anything you type in here is just like typing directly in the core |
| 23 | + # source files and will be run when the controller class is loaded. |
| 24 | + end |
25 | 25 |
|
26 |
| - module InstanceMethods |
27 |
| - |
28 |
| - # new method - fetches only the toplevel projects |
29 |
| - def find_toplevel_projects |
30 |
| - queryResult = ActiveRecord::Base.connection.exec_query(" |
31 |
| - select p.id |
32 |
| - from |
33 |
| - #{Project.table_name} p |
34 |
| - where |
35 |
| - p.parent_id is null") |
36 |
| - |
37 |
| - # load project as object and store it to the result |
38 |
| - result = [] |
39 |
| - queryResult.each do |row| |
40 |
| - result << Project.find(row['id']) |
41 |
| - end |
42 |
| - |
43 |
| - return result |
44 |
| - end |
45 |
| - |
46 |
| - |
47 |
| - #Insert overrides here |
48 |
| - #def new_method_with_old_method |
49 |
| - # your code |
50 |
| - #end |
51 |
| - end |
52 |
| - end |
53 |
| - end |
| 26 | + module InstanceMethods |
| 27 | + |
| 28 | + # new method - fetches only the toplevel projects |
| 29 | + def find_toplevel_projects |
| 30 | + queryResult = ActiveRecord::Base.connection.exec_query(" |
| 31 | + select p.id |
| 32 | + from |
| 33 | + #{Project.table_name} p |
| 34 | + where |
| 35 | + p.parent_id is null |
| 36 | + and p.status = 1") |
| 37 | + |
| 38 | + # load project as object and store it to the result |
| 39 | + result = [] |
| 40 | + queryResult.each do |row| |
| 41 | + result << Project.find(row['id']) |
| 42 | + end |
| 43 | + |
| 44 | + return result |
| 45 | + end |
| 46 | + |
| 47 | + |
| 48 | + #Insert overrides here |
| 49 | + #def new_method_with_old_method |
| 50 | + # your code |
| 51 | + #end |
| 52 | + end |
| 53 | + end |
| 54 | + end |
54 | 55 | end
|
55 | 56 |
|
56 | 57 | ProjectsHelper.send(:include, ProjectTree::Patches::ProjectsHelperPatch)
|
0 commit comments