Module: Drafteable::InstanceMethods

Defined in:
lib/drafteable.rb

Instance Method Summary collapse

Instance Method Details

#draft!Object



18
19
20
21
# File 'lib/drafteable.rb', line 18

def draft!
  self.draft = true
  self.save(validate: false)
end

#publish!Object



23
24
25
26
# File 'lib/drafteable.rb', line 23

def publish!
  self.draft = false
  self.save
end

#published?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/drafteable.rb', line 10

def published?
  begin
    !self.draft
  rescue NoMethodError
    raise Exception.new('There is no draft field. Did you forget to run migrations?')
  end
end