Module: Publishus::InstanceMethods

Defined in:
lib/publishus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#proper_destroyObject

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

Returns:

  • (Boolean)


36
37
38
# File 'lib/publishus.rb', line 36

def current?
  self.published_at.nil? || (self.published_at >= self.updated_at)
end

#liveObject



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

Returns:

  • (Boolean)


62
63
64
# File 'lib/publishus.rb', line 62

def published?
  !self.published_at.nil?
end

#real_destroyObject



48
49
50
51
# File 'lib/publishus.rb', line 48

def real_destroy
  @proper_destroy = true
  destroy
end