Class: Drupal::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/drupal/node.rb

Instance Method Summary collapse

Instance Method Details

#assign_vidObject



15
16
17
18
19
20
21
# File 'lib/drupal/node.rb', line 15

def assign_vid
  return true unless vid.nil? 
  self.vid ||= Drupal::Node.all.last.nid + 1
  save!
  self.vid = nid
  save!
end

#find_or_init_node_revisionObject



36
37
38
39
# File 'lib/drupal/node.rb', line 36

def find_or_init_node_revision
  return node_revision if node_revision
  @node_revision = Drupal::NodeRevision.new
end

#node_revisionObject



41
42
43
# File 'lib/drupal/node.rb', line 41

def node_revision
  @node_revision ||= Drupal::NodeRevision.get vid
end

#write_node_revisionObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/drupal/node.rb', line 23

def write_node_revision
  find_or_init_node_revision.attributes = {
    :nid     => nid,
    :vid     => vid, 
    :uid     => uid, 
    :title   => title,
    :body    => '',
    :teaser  => '',
    :log     => ''
  }
  node_revision.save!
end