Module: ConcernsOnRails::Publishable

Extended by:
ActiveSupport::Concern
Defined in:
lib/concerns_on_rails/publishable.rb

Instance Method Summary collapse

Instance Method Details

#publish!Object

Instance methods Publish the record Example:

record.publish!


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

def publish!
  update(self.class.publishable_field => Time.zone.now)
end

#published?Boolean

Check if the record is published Example:

record.published?

Returns:

  • (Boolean)


50
51
52
# File 'lib/concerns_on_rails/publishable.rb', line 50

def published?
  self[self.class.publishable_field].present?
end

#unpublish!Object

Unpublish the record Example:

record.unpublish!


43
44
45
# File 'lib/concerns_on_rails/publishable.rb', line 43

def unpublish!
  update(self.class.publishable_field => nil)
end

#unpublished?Boolean

Check if the record is unpublished Example:

record.unpublished?

Returns:

  • (Boolean)


57
58
59
# File 'lib/concerns_on_rails/publishable.rb', line 57

def unpublished?
  !published?
end