public
Description: Uber lightweight Merb blogging engine. Make sure you check out the feather-plugins repo as well!
Clone URL: git://github.com/mleung/feather.git
Click here to lend your support to: feather and make a donation at www.pledgie.com !
Cleaned up setting the :published attribute

* No more Article#is_published. Just use the built-in #published?
dstrelau (author)
Thu Jun 26 21:06:46 -0700 2008
commit  cd979c3253173fc802b9fa62bd9afab2ab97fe09
tree    2d69b8b52db8e9cf4f919d420245d71dd92c2170
parent  b38aecb1fbcc97c8fcd580b3fb6b5bab987bba27
...
18
19
20
21
22
23
24
25
26
27
28
 
29
30
31
...
38
39
40
41
42
43
44
45
46
47
48
 
49
50
51
...
18
19
20
 
21
22
23
24
25
26
 
27
28
29
30
...
37
38
39
 
40
41
42
43
44
45
 
46
47
48
49
0
@@ -18,14 +18,13 @@ module Admin
0
     
0
     def create(article)
0
       @article = Article.new(article)
0
- @article.published = true if @article.published == "1"
0
       @article.user_id = self.current_user.id
0
       if @article.save
0
         # Expire the article index to reflect the newly published article
0
         expire_index if @article.published
0
         render_then_call(redirect(url(:admin_articles))) do
0
           # Call events after the redirect
0
- Hooks::Events.after_publish_article_request(@article, request) if @article.is_published?
0
+ Hooks::Events.after_publish_article_request(@article, request) if @article.published?
0
           Hooks::Events.after_create_article_request(@article, request)
0
         end
0
       else
0
@@ -38,14 +37,13 @@ module Admin
0
     end
0
     
0
     def update(article)
0
- article["published"] = true if article["published"] == "1"
0
       if @article.update_attributes(article)
0
         # Expire the index and article to reflect the updated article
0
         expire_index
0
         expire_article(@article)
0
         render_then_call(redirect(url(:admin_article, @article))) do
0
           # Call events after the redirect
0
- Hooks::Events.after_publish_article_request(@article, request) if @article.is_published?
0
+ Hooks::Events.after_publish_article_request(@article, request) if @article.published?
0
           Hooks::Events.after_update_article_request(@article, request)
0
         end
0
       else
...
36
37
38
39
 
40
41
 
42
43
44
...
68
69
70
71
 
72
73
74
...
81
82
83
84
 
85
86
87
 
88
89
 
90
91
92
...
36
37
38
 
39
40
 
41
42
43
44
...
68
69
70
 
71
72
73
74
...
81
82
83
 
84
85
86
 
87
88
 
89
90
91
92
0
@@ -36,9 +36,9 @@ class Article
0
   # This sets the published date and permalink when an article is published
0
   def set_published_permalink
0
     # Check to see if we are publishing
0
- if self.is_published?
0
+ if self.published?
0
       # Set the date, only if we haven't already
0
- self.published_at = Time.now if self.published_at.nil?
0
+ self.published_at ||= Time.now
0
       
0
       # Set the permalink, only if we haven't already
0
       self.permalink = create_permalink
0
@@ -68,7 +68,7 @@ class Article
0
 
0
   def fire_before_save_event
0
     Hooks::Events.before_save_article(self)
0
- Hooks::Events.before_publish_article(self) if self.is_published?
0
+ Hooks::Events.before_publish_article(self) if self.published?
0
   end
0
 
0
   def fire_after_create_event
0
@@ -81,12 +81,12 @@ class Article
0
 
0
   def fire_after_save_event
0
     Hooks::Events.after_save_article(self)
0
- Hooks::Events.after_publish_article(self) if self.is_published?
0
+ Hooks::Events.after_publish_article(self) if self.published?
0
   end
0
 
0
- def is_published?
0
+ def published=(binary_string)
0
     # We need this beacuse the values get populated from the params
0
- self.published == "1" || self.published
0
+ attribute_set(:published, binary_string == "1")
0
   end
0
   
0
   def create_permalink

Comments

    No one has commented yet.