Module: Pubdraft::InstanceMethods
- Defined in:
- lib/pubdraft.rb
Class Method Summary collapse
Instance Method Summary collapse
- #draft ⇒ Object
- #draft! ⇒ Object
- #drafted? ⇒ Boolean
- #publish ⇒ Object
- #publish! ⇒ Object
- #published? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/pubdraft.rb', line 5 def self.included(base) base.send :before_create, :set_pubdraft_state base.attr_accessible :state base.scope :published, base.where(:state => 'published') base.scope :drafted, base.where(:state => 'drafted') end |
Instance Method Details
#draft ⇒ Object
33 34 35 |
# File 'lib/pubdraft.rb', line 33 def draft self.state = 'drafted' end |
#draft! ⇒ Object
29 30 31 |
# File 'lib/pubdraft.rb', line 29 def draft! draft && save end |
#drafted? ⇒ Boolean
17 18 19 |
# File 'lib/pubdraft.rb', line 17 def drafted? state == 'drafted' end |
#publish ⇒ Object
25 26 27 |
# File 'lib/pubdraft.rb', line 25 def publish self.state = 'published' end |
#publish! ⇒ Object
21 22 23 |
# File 'lib/pubdraft.rb', line 21 def publish! publish && save end |
#published? ⇒ Boolean
13 14 15 |
# File 'lib/pubdraft.rb', line 13 def published? state == 'published' end |