Module: Hideable::ActiveRecord

Defined in:
lib/hideable/active_record.rb,
lib/hideable/active_record/instance_methods.rb

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Instance Method Details

#hiddenObject



14
15
16
# File 'lib/hideable/active_record.rb', line 14

def hidden
  where(self.arel_table[:hidden_at].not_eq(nil))
end

#hideable(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/hideable/active_record.rb', line 4

def hideable(options = {})
  send :include, InstanceMethods
  class_attribute :hide_dependents
  self.hide_dependents = (options[:dependent] == :hide) ? true : false
  after_save :update_hideable_dependents!, :if => :update_hideable_dependents?
  if options[:updated]
    after_save options[:updated]
  end
end

#not_hiddenObject



18
19
20
# File 'lib/hideable/active_record.rb', line 18

def not_hidden
  where(self.arel_table[:hidden_at].eq(nil))
end