Class: Pliable::Ply

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/pliable/ply.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pliable/ply.rb', line 21

def self.all
  if current_scope
    current_scope.clone
  else
    if self.name == "Pliable::Ply"
      scope = relation
    else
      if self.try(:ply_type)
        scope = relation.where(otype: self.try(:ply_type))
      else
        scope = relation
      end
    end
    default_scoped
  end
end

.oldest_last_checked_timeObject



17
18
19
# File 'lib/pliable/ply.rb', line 17

def self.oldest_last_checked_time
  order('last_checked').first.last_checked
end

.ply_name(name) ⇒ Object



38
39
40
# File 'lib/pliable/ply.rb', line 38

def self.ply_name(name)
  define_singleton_method(:ply_type) { name }
end

Instance Method Details

#child_idsObject



42
43
44
# File 'lib/pliable/ply.rb', line 42

def child_ids
  child_relations.map(&:child_id)
end

#parent_idsObject



46
47
48
# File 'lib/pliable/ply.rb', line 46

def parent_ids
  parent_relations.map(&:parent_id)
end

#to_paramObject



50
51
52
# File 'lib/pliable/ply.rb', line 50

def to_param
  oid
end