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.


18
19
20
21
22
# File 'lib/rom/repository/session.rb', line 18

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.


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

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.


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

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.


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

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.


24
25
26
27
# File 'lib/rom/repository/session.rb', line 24

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.


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

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)

50
51
52
# File 'lib/rom/repository/session.rb', line 50

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)

42
43
44
# File 'lib/rom/repository/session.rb', line 42

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)

46
47
48
# File 'lib/rom/repository/session.rb', line 46

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