Module: Closet::Bury::InstanceMethods

Defined in:
lib/closet/bury/instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#buried?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/closet/bury/instance_methods.rb', line 25

def buried?
  self.reload && self.buried_at != nil
end

#bury(options = { dependent: true }) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/closet/bury/instance_methods.rb', line 5

def bury( options = { dependent: true } )
  begin
    self.bury!( dependent: options.with_indifferent_access[:dependent] )
  rescue
    false
  end
end

#bury!(options = { dependent: true }) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/closet/bury/instance_methods.rb', line 13

def bury!( options= { dependent: true } )
  if options.with_indifferent_access[:dependent]
    ActiveRecord::Base.transaction do
      run_callbacks( :bury ) do
        flag_as_buried
      end
    end
  else
    flag_as_buried
  end
end