Module: Publishus::InstanceMethods
- Defined in:
- lib/publishus.rb
Instance Attribute Summary collapse
-
#proper_destroy ⇒ Object
Returns the value of attribute proper_destroy.
Instance Method Summary collapse
- #current? ⇒ Boolean
- #live ⇒ Object
- #publish!(time = nil) ⇒ Object
- #publish_all! ⇒ Object
- #published? ⇒ Boolean
- #real_destroy ⇒ Object
Instance Attribute Details
#proper_destroy ⇒ Object
Returns the value of attribute proper_destroy.
46 47 48 |
# File 'lib/publishus.rb', line 46 def proper_destroy @proper_destroy end |
Instance Method Details
#current? ⇒ Boolean
36 37 38 |
# File 'lib/publishus.rb', line 36 def current? self.published_at.nil? || (self.published_at >= self.updated_at) end |
#live ⇒ Object
40 41 42 43 44 |
# File 'lib/publishus.rb', line 40 def live returning self do |publishable| publishable.revert_to(publishable.published_at) unless publishable.current? end end |
#publish!(time = nil) ⇒ Object
53 54 55 |
# File 'lib/publishus.rb', line 53 def publish!(time=nil) self.update_attribute(:published_at, time||Time.now) end |
#publish_all! ⇒ Object
57 58 59 60 |
# File 'lib/publishus.rb', line 57 def publish_all! time = Time.now all.each { |publishable| publishable.publish!(time) } end |
#published? ⇒ Boolean
62 63 64 |
# File 'lib/publishus.rb', line 62 def published? !self.published_at.nil? end |
#real_destroy ⇒ Object
48 49 50 51 |
# File 'lib/publishus.rb', line 48 def real_destroy @proper_destroy = true destroy end |