summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Update.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Update.rb b/lib/Update.rb
new file mode 100644
index 0000000..480bb0b
--- /dev/null
+++ b/lib/Update.rb
@@ -0,0 +1,17 @@
1module Update
2
3 def self.find_or_create_parent
4 current_year = Time.now.year.to_s
5
6 if parent = Node.find_by_unique_name("updates/#{current_year}")
7 parent
8 else
9 unless updates = Node.find_by_unique_name("updates")
10 updates = Node.root.children.create(:slug => "updates")
11 end
12 parent = updates.children.create(:slug => current_year)
13 parent
14 end
15 end
16
17end \ No newline at end of file