Class: Y::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/y/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc = nil) ⇒ Transaction

Returns a new instance of Transaction.



10
11
12
13
14
# File 'lib/y/transaction.rb', line 10

def initialize(doc = nil)
  @document = doc

  super()
end

Instance Attribute Details

#documentY::Doc

Returns The document this array belongs to.

Returns:

  • (Y::Doc)

    The document this array belongs to



8
9
10
# File 'lib/y/transaction.rb', line 8

def document
  @document
end

Instance Method Details

#apply(update) ⇒ void

This method returns an undefined value.

Applies the encoded update on this document. This will bring the the document to the same state as the one the update is from.

Parameters:

  • update (::Array<Integer>)


21
22
23
# File 'lib/y/transaction.rb', line 21

def apply(update)
  ytransaction_apply_update(update)
end

#apply_v2(update) ⇒ void

This method returns an undefined value.

Applies the v2 encoded update on this document. This will bring the the document to the same state as the one the update is from.

Parameters:

  • update (::Array<Integer>)


30
31
32
# File 'lib/y/transaction.rb', line 30

def apply_v2(update)
  ytransaction_apply_update_v2(update)
end

#commitvoid

This method returns an undefined value.

Commits transaction



37
38
39
# File 'lib/y/transaction.rb', line 37

def commit
  ytransaction_commit
end

#get_array(name) ⇒ Y::Array

Create or get array type

Parameters:

  • name (String)

Returns:



45
46
47
48
49
# File 'lib/y/transaction.rb', line 45

def get_array(name)
  array = ytransaction_get_array(name)
  array.document = document
  array
end

#get_map(name) ⇒ Y::Map

Create or get map type

Parameters:

  • name (String)

Returns:



55
56
57
58
59
# File 'lib/y/transaction.rb', line 55

def get_map(name)
  map = ytransaction_get_map(name)
  map.document = document
  map
end

#get_text(name) ⇒ Y::Text

Create or get text type

Parameters:

  • name (String)

Returns:



65
66
67
68
69
# File 'lib/y/transaction.rb', line 65

def get_text(name)
  text = ytransaction_get_text(name)
  text.document = document
  text
end

#get_xml_element(name) ⇒ Y::XMLElement

Create or get XMLElement type

Parameters:

  • name (String)

Returns:



75
76
77
78
79
# File 'lib/y/transaction.rb', line 75

def get_xml_element(name)
  xml_element = ytransaction_get_xml_element(name)
  xml_element.document = document
  xml_element
end

#get_xml_fragment(name) ⇒ Y::XMLFragment

Create or get XMLFragment type

Parameters:

  • name (String)

Returns:

  • (Y::XMLFragment)


85
86
87
88
89
# File 'lib/y/transaction.rb', line 85

def get_xml_fragment(name)
  xml_fragment = ytransaction_get_xml_fragment(name)
  xml_fragment.document = document
  xml_fragment
end

#get_xml_text(name) ⇒ Y::XMLText

Create or get XMLText type

Parameters:

  • name (String)

Returns:



95
96
97
98
99
# File 'lib/y/transaction.rb', line 95

def get_xml_text(name)
  xml_text = ytransaction_get_xml_text(name)
  xml_text.document = document
  xml_text
end

#state::Array<Integer>

Return a state vector for this transaction

Returns:

  • (::Array<Integer>)


104
105
106
# File 'lib/y/transaction.rb', line 104

def state
  ytransaction_state_vector
end

#state_v2::Array<Integer>

Returns a v2 state vector for this transaction

Returns:

  • (::Array<Integer>)


111
112
113
# File 'lib/y/transaction.rb', line 111

def state_v2
  ytransaction_state_vector_v2
end