Class: ROM::Session Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/repository/session.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

TODO: finish this in 1.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Session

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Session.



16
17
18
19
20
# File 'lib/rom/repository/session.rb', line 16

def initialize(repo)
  @repo = repo
  @status = :pending
  initialize_queue!
end

Instance Attribute Details

#queueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/rom/repository/session.rb', line 12

def queue
  @queue
end

#repoObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/rom/repository/session.rb', line 10

def repo
  @repo
end

#statusObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/rom/repository/session.rb', line 14

def status
  @status
end

Instance Method Details

#add(changeset) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
# File 'lib/rom/repository/session.rb', line 22

def add(changeset)
  queue << changeset
  self
end

#commit!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rom/repository/session.rb', line 27

def commit!
  queue.each(&:commit)

  @status = :success

  self
rescue StandardError => e
  @status = :failure
  raise e
ensure
  initialize_queue!
end

#failure?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


48
49
50
# File 'lib/rom/repository/session.rb', line 48

def failure?
  status.equal?(:failure)
end

#pending?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


40
41
42
# File 'lib/rom/repository/session.rb', line 40

def pending?
  status.equal?(:pending)
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


44
45
46
# File 'lib/rom/repository/session.rb', line 44

def success?
  status.equal?(:success)
end