y-rb 0.6.0-x86_64-linux-gnu

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,189 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Y
4
+ class Transaction
5
+ # @!attribute [r] document
6
+ #
7
+ # @return [Y::Doc] The document this array belongs to
8
+ attr_accessor :document
9
+
10
+ def initialize(doc = nil)
11
+ @document = doc
12
+
13
+ super()
14
+ end
15
+
16
+ # Applies the encoded update on this document. This will bring the
17
+ # the document to the same state as the one the update is from.
18
+ #
19
+ # @param update [::Array<Integer>]
20
+ # @return [void]
21
+ def apply(update)
22
+ ytransaction_apply_update(update)
23
+ end
24
+
25
+ # Applies the v2 encoded update on this document. This will bring the
26
+ # the document to the same state as the one the update is from.
27
+ #
28
+ # @param update [::Array<Integer>]
29
+ # @return [void]
30
+ def apply_v2(update)
31
+ ytransaction_apply_update_v2(update)
32
+ end
33
+
34
+ # Commits transaction
35
+ #
36
+ # @return [void]
37
+ def commit
38
+ ytransaction_commit
39
+ end
40
+
41
+ # Create or get array type
42
+ #
43
+ # @param name [String]
44
+ # @return [Y::Array]
45
+ def get_array(name)
46
+ array = ytransaction_get_array(name)
47
+ array.document = document
48
+ array
49
+ end
50
+
51
+ # Create or get map type
52
+ #
53
+ # @param name [String]
54
+ # @return [Y::Map]
55
+ def get_map(name)
56
+ map = ytransaction_get_map(name)
57
+ map.document = document
58
+ map
59
+ end
60
+
61
+ # Create or get text type
62
+ #
63
+ # @param name [String]
64
+ # @return [Y::Text]
65
+ def get_text(name)
66
+ text = ytransaction_get_text(name)
67
+ text.document = document
68
+ text
69
+ end
70
+
71
+ # Create or get XMLElement type
72
+ #
73
+ # @param name [String]
74
+ # @return [Y::XMLElement]
75
+ def get_xml_element(name)
76
+ xml_element = ytransaction_get_xml_element(name)
77
+ xml_element.document = document
78
+ xml_element
79
+ end
80
+
81
+ # Create or get XMLFragment type
82
+ #
83
+ # @param name [String]
84
+ # @return [Y::XMLFragment]
85
+ def get_xml_fragment(name)
86
+ xml_fragment = ytransaction_get_xml_fragment(name)
87
+ xml_fragment.document = document
88
+ xml_fragment
89
+ end
90
+
91
+ # Create or get XMLText type
92
+ #
93
+ # @param name [String]
94
+ # @return [Y::XMLText]
95
+ def get_xml_text(name)
96
+ xml_text = ytransaction_get_xml_text(name)
97
+ xml_text.document = document
98
+ xml_text
99
+ end
100
+
101
+ # Return a state vector for this transaction
102
+ #
103
+ # @return [::Array<Integer>]
104
+ def state
105
+ ytransaction_state_vector
106
+ end
107
+
108
+ # Returns a v2 state vector for this transaction
109
+ #
110
+ # @return [::Array<Integer>]
111
+ def state_v2
112
+ ytransaction_state_vector_v2
113
+ end
114
+
115
+ # @!method ytransaction_apply_update(update)
116
+ # Apply the encoded update within current transaction
117
+ #
118
+ # @param update [::Array<Integer>]
119
+ # @return [void]
120
+ # @!visibility private
121
+
122
+ # @!method ytransaction_apply_update_v2(update)
123
+ # Apply the v2 encoded update within current transaction
124
+ #
125
+ # @param update [::Array<Integer>]
126
+ # @return [void]
127
+ # @!visibility private
128
+
129
+ # @!method ytransaction_commit()
130
+ #
131
+ # @return [void]
132
+ # @!visibility private
133
+
134
+ # @!method ytransaction_get_array(name)
135
+ # Returns or creates an array by name
136
+ #
137
+ # @param name [String] Name of the array structure to retrieve or create
138
+ # @return [Y::Array] Array structure
139
+ # @!visibility private
140
+
141
+ # @!method ytransaction_get_map(name)
142
+ # Returns or creates a map structure by name
143
+ #
144
+ # @param name [String] Name of the map structure to retrieve or create
145
+ # @return [Y::Map] Map structure
146
+ # @!visibility private
147
+
148
+ # @!method ytransaction_get_text(name)
149
+ # Returns or creates a text structure by name
150
+ #
151
+ # @param name [String] Name of the text structure to retrieve or create
152
+ # @return [Y::Text] Text structure
153
+ # @!visibility private
154
+
155
+ # @!method ytransaction_get_xml_element(name)
156
+ # Returns or creates a XML structure by name
157
+ #
158
+ # @param name [String] Name of the XML element structure to retrieve or
159
+ # create
160
+ # @return [Y::XMLElement] XMLElement structure
161
+ # @!visibility private
162
+
163
+ # @!method ytransaction_get_xml_fragment(name)
164
+ # Returns or creates a XML fragment
165
+ #
166
+ # @param name [String] Name of the XML fragment to retrieve or
167
+ # create by
168
+ # @return [Y::XMLFragment] XMLFragment structure
169
+ # @!visibility private
170
+
171
+ # @!method ytransaction_get_xml_text(name)
172
+ # Returns or creates a XML structure by name
173
+ #
174
+ # @param name [String] Name of the XML element structure to retrieve or
175
+ # create
176
+ # @return [Y::XMLElement] XMLElement structure
177
+ # @!visibility private
178
+
179
+ # @!method ytransaction_state_vector
180
+ #
181
+ # @return [Array<Integer>]
182
+ # @!visibility private
183
+
184
+ # @!method ytransaction_state_vector_v2
185
+ #
186
+ # @return [Array<Integer>]
187
+ # @!visibility private
188
+ end
189
+ end
data/lib/y/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Y
4
+ VERSION = "0.6.0"
5
+ end