y-rb 0.1.7-x86_64-linux → 0.3.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,10 +16,7 @@ pub(crate) struct YTransaction(pub(crate) RefCell<Transaction>);
16
16
  unsafe impl Send for YTransaction {}
17
17
 
18
18
  impl YTransaction {
19
- pub(crate) fn ytransaction_apply_update(
20
- &self,
21
- update: Vec<u8>
22
- ) -> Result<(), Error> {
19
+ pub(crate) fn ytransaction_apply_update(&self, update: Vec<u8>) -> Result<(), Error> {
23
20
  return Update::decode_v1(update.as_slice())
24
21
  .map(|u| self.0.borrow_mut().apply_update(u))
25
22
  .map_err(|_e| Error::runtime_error("cannot apply update"));
@@ -30,30 +27,27 @@ impl YTransaction {
30
27
  pub(crate) fn ytransaction_get_array(&self, name: String) -> YArray {
31
28
  let a = self.0.borrow_mut().get_array(&*name);
32
29
 
33
- return YArray(RefCell::from(a));
30
+ YArray(RefCell::from(a))
34
31
  }
35
32
  pub(crate) fn ytransaction_get_map(&self, name: String) -> YMap {
36
33
  let m = self.0.borrow_mut().get_map(&*name);
37
34
 
38
- return YMap(RefCell::from(m));
35
+ YMap(RefCell::from(m))
39
36
  }
40
37
  pub(crate) fn ytransaction_get_text(&self, name: String) -> YText {
41
38
  let t = self.0.borrow_mut().get_text(&*name);
42
39
 
43
- return YText(RefCell::new(t));
40
+ YText(RefCell::new(t))
44
41
  }
45
- pub(crate) fn ytransaction_get_xml_element(
46
- &self,
47
- name: String
48
- ) -> YXmlElement {
42
+ pub(crate) fn ytransaction_get_xml_element(&self, name: String) -> YXmlElement {
49
43
  let el = self.0.borrow_mut().get_xml_element(&*name);
50
44
 
51
- return YXmlElement(RefCell::new(el));
45
+ YXmlElement(RefCell::new(el))
52
46
  }
53
47
  pub(crate) fn ytransaction_get_xml_text(&self, name: String) -> YXmlText {
54
48
  let t = self.0.borrow_mut().get_xml_text(&*name);
55
49
 
56
- return YXmlText(RefCell::new(t));
50
+ YXmlText(RefCell::new(t))
57
51
  }
58
52
  pub(crate) fn ytransaction_state_vector(&self) -> Vec<u8> {
59
53
  return self.0.borrow_mut().state_vector().encode_v1();
@@ -2,15 +2,11 @@ use crate::{YText, YXmlElement, YXmlText};
2
2
  use lib0::any::Any;
3
3
  use magnus::r_hash::ForEach::Continue;
4
4
  use magnus::value::Qnil;
5
- use magnus::{
6
- class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL
7
- };
5
+ use magnus::{class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL};
8
6
  use std::cell::RefCell;
9
7
  use std::collections::HashMap;
10
8
  use yrs::types::Value as YrsValue;
11
- use yrs::{
12
- Text as YrsText, XmlElement as YrsXmlElement, XmlText as YrsXmlText
13
- };
9
+ use yrs::{Text as YrsText, XmlElement as YrsXmlElement, XmlText as YrsXmlText};
14
10
 
15
11
  pub(crate) struct YValue(pub(crate) RefCell<Value>);
16
12
 
@@ -77,7 +73,7 @@ impl From<YrsText> for YValue {
77
73
  impl From<YrsXmlElement> for YValue {
78
74
  fn from(value: YrsXmlElement) -> Self {
79
75
  YValue(RefCell::from(Value::from(YXmlElement(RefCell::from(
80
- value
76
+ value,
81
77
  )))))
82
78
  }
83
79
  }
@@ -150,10 +146,7 @@ impl From<YrsValue> for YValue {
150
146
  // *yvalue.0
151
147
  // }))),
152
148
  // YrsValue::YMap(val) => YValue::from(RHash::from_iter(val.iter())),
153
- v => panic!(
154
- "cannot map complex yrs values to yvalue: {}",
155
- v.to_string()
156
- )
149
+ v => panic!("cannot map complex yrs values to yvalue: {}", v.to_string()),
157
150
  }
158
151
  }
159
152
  }
@@ -215,6 +208,7 @@ impl From<YValue> for Any {
215
208
  }
216
209
  }
217
210
 
211
+ #[allow(clippy::from_over_into)]
218
212
  impl Into<Value> for YValue {
219
213
  fn into(self) -> Value {
220
214
  self.0.into_inner()
@@ -15,7 +15,7 @@ unsafe impl Send for YXmlElement {}
15
15
 
16
16
  impl YXmlElement {
17
17
  pub(crate) fn yxml_element_attributes(&self) -> RHash {
18
- RHash::from_iter(self.0.borrow().attributes().into_iter())
18
+ RHash::from_iter(self.0.borrow().attributes())
19
19
  }
20
20
  pub(crate) fn yxml_element_first_child(&self) -> Option<Value> {
21
21
  self.yxml_element_get(0)
@@ -23,45 +23,39 @@ impl YXmlElement {
23
23
  pub(crate) fn yxml_element_get(&self, index: u32) -> Option<Value> {
24
24
  self.0.borrow().get(index).map(|node| match node {
25
25
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
26
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
26
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
27
27
  })
28
28
  }
29
- pub(crate) fn yxml_element_get_attribute(
30
- &self,
31
- name: String
32
- ) -> Option<String> {
29
+ pub(crate) fn yxml_element_get_attribute(&self, name: String) -> Option<String> {
33
30
  self.0.borrow().get_attribute(&*name)
34
31
  }
35
32
  pub(crate) fn yxml_element_insert_attribute(
36
33
  &self,
37
34
  transaction: &YTransaction,
38
35
  name: String,
39
- value: String
36
+ value: String,
40
37
  ) {
41
- self.0.borrow_mut().insert_attribute(
42
- &mut *transaction.0.borrow_mut(),
43
- name,
44
- value
45
- );
38
+ self.0
39
+ .borrow_mut()
40
+ .insert_attribute(&mut *transaction.0.borrow_mut(), name, value);
46
41
  }
47
42
  pub(crate) fn yxml_element_insert_element(
48
43
  &self,
49
44
  transaction: &YTransaction,
50
45
  index: u32,
51
- name: String
46
+ name: String,
52
47
  ) -> YXmlElement {
53
- let element = self.0.borrow_mut().insert_elem(
54
- &mut *transaction.0.borrow_mut(),
55
- index,
56
- name
57
- );
48
+ let element =
49
+ self.0
50
+ .borrow_mut()
51
+ .insert_elem(&mut *transaction.0.borrow_mut(), index, name);
58
52
 
59
53
  YXmlElement(RefCell::from(element))
60
54
  }
61
55
  pub(crate) fn yxml_element_insert_text(
62
56
  &self,
63
57
  transaction: &YTransaction,
64
- index: u32
58
+ index: u32,
65
59
  ) -> YXmlText {
66
60
  let text = self
67
61
  .0
@@ -73,19 +67,18 @@ impl YXmlElement {
73
67
  pub(crate) fn yxml_element_next_sibling(&self) -> Option<Value> {
74
68
  self.0.borrow().next_sibling().map(|item| match item {
75
69
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
76
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
70
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
77
71
  })
78
72
  }
79
- pub(crate) fn yxml_element_observe(
80
- &self,
81
- block: Proc
82
- ) -> Result<u32, Error> {
73
+ pub(crate) fn yxml_element_observe(&self, block: Proc) -> Result<u32, Error> {
83
74
  let change_added = Symbol::new("added").to_static();
84
75
  let change_retain = Symbol::new("retain").to_static();
85
76
  let change_removed = Symbol::new("removed").to_static();
86
77
 
87
- let subscription_id = self.0.borrow_mut().observe(
88
- move |transaction, xml_element_event| {
78
+ let subscription_id = self
79
+ .0
80
+ .borrow_mut()
81
+ .observe(move |transaction, xml_element_event| {
89
82
  let delta = xml_element_event.delta(transaction);
90
83
  let changes = RArray::with_capacity(delta.len());
91
84
 
@@ -103,9 +96,9 @@ impl YXmlElement {
103
96
  .aset(change_added, RArray::from_vec(values))
104
97
  .expect("cannot create change::added payload");
105
98
 
106
- changes.push(payload).expect(
107
- "cannot push payload to list of changes"
108
- );
99
+ changes
100
+ .push(payload)
101
+ .expect("cannot push payload to list of changes");
109
102
  }
110
103
  Change::Retain(position) => {
111
104
  let payload = RHash::new();
@@ -113,19 +106,19 @@ impl YXmlElement {
113
106
  .aset(change_retain, *position)
114
107
  .expect("cannot create change::retain payload");
115
108
 
116
- changes.push(payload).expect(
117
- "cannot push payload to list of changes"
118
- );
109
+ changes
110
+ .push(payload)
111
+ .expect("cannot push payload to list of changes");
119
112
  }
120
113
  Change::Removed(position) => {
121
114
  let payload = RHash::new();
122
- payload.aset(change_removed, *position).expect(
123
- "cannot create change::removed payload"
124
- );
115
+ payload
116
+ .aset(change_removed, *position)
117
+ .expect("cannot create change::removed payload");
125
118
 
126
- changes.push(payload).expect(
127
- "cannot push payload to list of changes"
128
- );
119
+ changes
120
+ .push(payload)
121
+ .expect("cannot push payload to list of changes");
129
122
  }
130
123
  }
131
124
  }
@@ -133,8 +126,7 @@ impl YXmlElement {
133
126
  block
134
127
  .call::<(RArray,), Value>((changes,))
135
128
  .expect("cannot call block");
136
- }
137
- );
129
+ });
138
130
 
139
131
  Ok(subscription_id.into())
140
132
  }
@@ -147,13 +139,13 @@ impl YXmlElement {
147
139
  pub(crate) fn yxml_element_prev_sibling(&self) -> Option<Value> {
148
140
  self.0.borrow().prev_sibling().map(|item| match item {
149
141
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
150
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
142
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
151
143
  })
152
144
  }
153
145
  pub(crate) fn yxml_element_push_element_back(
154
146
  &self,
155
147
  transaction: &YTransaction,
156
- name: String
148
+ name: String,
157
149
  ) -> YXmlElement {
158
150
  let xml_element = self
159
151
  .0
@@ -165,7 +157,7 @@ impl YXmlElement {
165
157
  pub(crate) fn yxml_element_push_element_front(
166
158
  &self,
167
159
  transaction: &YTransaction,
168
- name: String
160
+ name: String,
169
161
  ) -> YXmlElement {
170
162
  let xml_element = self
171
163
  .0
@@ -174,10 +166,7 @@ impl YXmlElement {
174
166
 
175
167
  YXmlElement(RefCell::from(xml_element))
176
168
  }
177
- pub(crate) fn yxml_element_push_text_back(
178
- &self,
179
- transaction: &YTransaction
180
- ) -> YXmlText {
169
+ pub(crate) fn yxml_element_push_text_back(&self, transaction: &YTransaction) -> YXmlText {
181
170
  let xml_text = self
182
171
  .0
183
172
  .borrow_mut()
@@ -185,10 +174,7 @@ impl YXmlElement {
185
174
 
186
175
  YXmlText(RefCell::from(xml_text))
187
176
  }
188
- pub(crate) fn yxml_element_push_text_front(
189
- &self,
190
- transaction: &YTransaction
191
- ) -> YXmlText {
177
+ pub(crate) fn yxml_element_push_text_front(&self, transaction: &YTransaction) -> YXmlText {
192
178
  let xml_text = self
193
179
  .0
194
180
  .borrow_mut()
@@ -196,27 +182,20 @@ impl YXmlElement {
196
182
 
197
183
  YXmlText(RefCell::from(xml_text))
198
184
  }
199
- pub(crate) fn yxml_element_remove_attribute(
200
- &self,
201
- transaction: &YTransaction,
202
- name: String
203
- ) {
204
- self.0.borrow_mut().remove_attribute::<&str>(
205
- &mut *transaction.0.borrow_mut(),
206
- &name.as_str()
207
- );
185
+ pub(crate) fn yxml_element_remove_attribute(&self, transaction: &YTransaction, name: String) {
186
+ self.0
187
+ .borrow_mut()
188
+ .remove_attribute::<&str>(&mut *transaction.0.borrow_mut(), &name.as_str());
208
189
  }
209
190
  pub(crate) fn yxml_element_remove_range(
210
191
  &self,
211
192
  transaction: &YTransaction,
212
193
  index: u32,
213
- length: u32
194
+ length: u32,
214
195
  ) {
215
- self.0.borrow_mut().remove_range(
216
- &mut *transaction.0.borrow_mut(),
217
- index,
218
- length
219
- );
196
+ self.0
197
+ .borrow_mut()
198
+ .remove_range(&mut *transaction.0.borrow_mut(), index, length);
220
199
  }
221
200
  pub(crate) fn yxml_element_size(&self) -> u32 {
222
201
  self.0.borrow().len()
@@ -14,60 +14,45 @@ unsafe impl Send for YXmlText {}
14
14
 
15
15
  impl YXmlText {
16
16
  pub(crate) fn yxml_text_attributes(&self) -> RHash {
17
- RHash::from_iter(self.0.borrow().attributes().into_iter())
17
+ RHash::from_iter(self.0.borrow().attributes())
18
18
  }
19
19
  pub(crate) fn yxml_text_format(
20
20
  &self,
21
21
  transaction: &YTransaction,
22
22
  index: u32,
23
23
  length: u32,
24
- attrs: RHash
24
+ attrs: RHash,
25
25
  ) -> Result<(), Error> {
26
26
  map_rhash_to_attrs(attrs).map(|a| {
27
- self.0.borrow_mut().format(
28
- &mut *transaction.0.borrow_mut(),
29
- index,
30
- length,
31
- a
32
- );
27
+ self.0
28
+ .borrow_mut()
29
+ .format(&mut *transaction.0.borrow_mut(), index, length, a);
33
30
  })
34
31
  }
35
- pub(crate) fn yxml_text_get_attribute(
36
- &self,
37
- name: String
38
- ) -> Option<String> {
32
+ pub(crate) fn yxml_text_get_attribute(&self, name: String) -> Option<String> {
39
33
  self.0.borrow().get_attribute(&*name)
40
34
  }
41
- pub(crate) fn yxml_text_insert(
42
- &self,
43
- transaction: &YTransaction,
44
- index: u32,
45
- content: String
46
- ) {
47
- self.0.borrow_mut().insert(
48
- &mut *transaction.0.borrow_mut(),
49
- index,
50
- &*content
51
- )
35
+ pub(crate) fn yxml_text_insert(&self, transaction: &YTransaction, index: u32, content: String) {
36
+ self.0
37
+ .borrow_mut()
38
+ .insert(&mut *transaction.0.borrow_mut(), index, &*content)
52
39
  }
53
40
  pub(crate) fn yxml_text_insert_attribute(
54
41
  &self,
55
42
  transaction: &YTransaction,
56
43
  name: String,
57
- value: String
44
+ value: String,
58
45
  ) {
59
- self.0.borrow_mut().insert_attribute(
60
- &mut *transaction.0.borrow_mut(),
61
- name,
62
- value
63
- )
46
+ self.0
47
+ .borrow_mut()
48
+ .insert_attribute(&mut *transaction.0.borrow_mut(), name, value)
64
49
  }
65
50
  pub(crate) fn yxml_text_insert_embed_with_attributes(
66
51
  &self,
67
52
  transaction: &YTransaction,
68
53
  index: u32,
69
54
  content: Value,
70
- attrs: RHash
55
+ attrs: RHash,
71
56
  ) -> Result<(), Error> {
72
57
  let yvalue = YValue::from(content);
73
58
  let avalue = Any::from(yvalue);
@@ -77,7 +62,7 @@ impl YXmlText {
77
62
  &mut *transaction.0.borrow_mut(),
78
63
  index,
79
64
  avalue,
80
- a
65
+ a,
81
66
  );
82
67
  })
83
68
  }
@@ -85,12 +70,12 @@ impl YXmlText {
85
70
  &self,
86
71
  transaction: &YTransaction,
87
72
  index: u32,
88
- embed: Value
73
+ embed: Value,
89
74
  ) {
90
75
  self.0.borrow_mut().insert_embed(
91
76
  &mut *transaction.0.borrow_mut(),
92
77
  index,
93
- Any::from(YValue::from(embed))
78
+ Any::from(YValue::from(embed)),
94
79
  )
95
80
  }
96
81
  pub(crate) fn yxml_text_insert_with_attributes(
@@ -98,14 +83,14 @@ impl YXmlText {
98
83
  transaction: &YTransaction,
99
84
  index: u32,
100
85
  content: String,
101
- attrs: RHash
86
+ attrs: RHash,
102
87
  ) -> Result<(), Error> {
103
88
  map_rhash_to_attrs(attrs).map(|a| {
104
89
  self.0.borrow_mut().insert_with_attributes(
105
90
  &mut *transaction.0.borrow_mut(),
106
91
  index,
107
92
  &*content,
108
- a
93
+ a,
109
94
  );
110
95
  })
111
96
  }
@@ -115,7 +100,7 @@ impl YXmlText {
115
100
  pub(crate) fn yxml_text_next_sibling(&self) -> Option<Value> {
116
101
  self.0.borrow().next_sibling().map(|item| match item {
117
102
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
118
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
103
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
119
104
  })
120
105
  }
121
106
  pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
@@ -127,14 +112,10 @@ impl YXmlText {
127
112
  pub(crate) fn yxml_text_prev_sibling(&self) -> Option<Value> {
128
113
  self.0.borrow().prev_sibling().map(|item| match item {
129
114
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
130
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
115
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
131
116
  })
132
117
  }
133
- pub(crate) fn yxml_text_push(
134
- &self,
135
- transaction: &YTransaction,
136
- content: String
137
- ) {
118
+ pub(crate) fn yxml_text_push(&self, transaction: &YTransaction, content: String) {
138
119
  self.0
139
120
  .borrow_mut()
140
121
  .push(&mut *transaction.0.borrow_mut(), &*content)
@@ -143,13 +124,11 @@ impl YXmlText {
143
124
  &self,
144
125
  transaction: &YTransaction,
145
126
  index: u32,
146
- length: u32
127
+ length: u32,
147
128
  ) {
148
- self.0.borrow_mut().remove_range(
149
- &mut *transaction.0.borrow_mut(),
150
- index,
151
- length
152
- );
129
+ self.0
130
+ .borrow_mut()
131
+ .remove_range(&mut *transaction.0.borrow_mut(), index, length);
153
132
  }
154
133
  pub(crate) fn yxml_text_to_s(&self) -> String {
155
134
  self.0.borrow().to_string()
data/lib/2.7/yrb.so CHANGED
Binary file
data/lib/3.0/yrb.so CHANGED
Binary file
data/lib/3.1/yrb.so CHANGED
Binary file
data/lib/y/array.rb CHANGED
@@ -20,6 +20,8 @@ module Y
20
20
  #
21
21
  # array.to_a == [1, 2, 3, 4, 5] # true
22
22
  class Array
23
+ include Enumerable
24
+
23
25
  # @!attribute [r] document
24
26
  #
25
27
  # @return [Y::Doc] The document this array belongs to
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Y
4
+ class Awareness
5
+ def apply_update(update)
6
+ yawareness_apply_update(update)
7
+ end
8
+
9
+ def clean_local_state
10
+ yawareness_clean_local_state
11
+ end
12
+
13
+ def client_id
14
+ yawareness_client_id
15
+ end
16
+
17
+ def clients
18
+ yawareness_clients
19
+ end
20
+
21
+ def local_state
22
+ yawareness_local_state
23
+ end
24
+
25
+ def local_state=(json)
26
+ yawareness_set_local_state(json)
27
+ end
28
+
29
+ def attach(callback, &block)
30
+ return yawareness_on_update(callback) unless callback.nil?
31
+
32
+ yawareness_on_update(block.to_proc) unless block.nil?
33
+ end
34
+
35
+ def detach(subscription_id)
36
+ yawareness_remove_on_update(subscription_id)
37
+ end
38
+
39
+ def remove_state(client_id)
40
+ yawareness_remove_state(client_id)
41
+ end
42
+
43
+ def update
44
+ yawareness_update
45
+ end
46
+
47
+ def update_with_clients(clients)
48
+ yawareness_update_with_clients(clients)
49
+ end
50
+
51
+ # rubocop:disable Lint/UselessAccessModifier
52
+ private
53
+
54
+ # @!method yawareness_apply_update(update)
55
+ # Applies an update
56
+ #
57
+ # @param [Y::AwarenessUpdate] A structure that represents an encodable state
58
+ # of an Awareness struct.
59
+
60
+ # @!method yawareness_clean_local_state
61
+ # Clears out a state of a current client , effectively marking it as
62
+ # disconnected.
63
+
64
+ # @!method yawareness_client_id
65
+ # Returns a globally unique client ID of an underlying Doc.
66
+ # @return [Integer] The Client ID
67
+
68
+ # @!method yawareness_clients
69
+ # Returns a state map of all of the clients
70
+ # tracked by current Awareness instance. Those states are identified by
71
+ # their corresponding ClientIDs. The associated state is represented and
72
+ # replicated to other clients as a JSON string.
73
+ #
74
+ # @return [Hash<Integer, String>] Map of clients
75
+
76
+ # @!method yawareness_local_state
77
+ #
78
+ # @return [String|nil] Returns a JSON string state representation of a
79
+ # current Awareness instance.
80
+
81
+ # @!method yawareness_on_update(callback, &block)
82
+ #
83
+ # @param [Proc] A callback handler for updates
84
+ # @return [Integer] The subscription ID
85
+
86
+ # @!method yawareness_remove_on_update(subscription_id)
87
+ #
88
+ # @param [Integer] subscription_id The subscription id to remove
89
+
90
+ # @!method yawareness_remove_state(client_id)
91
+ # Clears out a state of a given client, effectively marking it as
92
+ # disconnected.
93
+ #
94
+ # @param [Integer] A Client ID
95
+ # @return [String|nil] Returns a JSON string state representation of a
96
+ # current Awareness instance.
97
+
98
+ # @!method yawareness_set_local_state(state)
99
+ # Sets a current Awareness instance state to a corresponding JSON string.
100
+ # This state will be replicated to other clients as part of the
101
+ # AwarenessUpdate and it will trigger an event to be emitted if current
102
+ # instance was created using [Awareness::with_observer] method.
103
+ #
104
+ # @param [String] Returns a state map of all of the clients tracked by
105
+ # current Awareness instance. Those states are identified by their
106
+ # corresponding ClientIDs. The associated state is represented and
107
+ # replicated to other clients as a JSON string.
108
+
109
+ # @!method yawareness_update
110
+ # Returns a serializable update object which is representation of a
111
+ # current Awareness state.
112
+ #
113
+ # @return [Y::AwarenessUpdate] The update object
114
+
115
+ # @!method yawareness_update_with_clients(clients)
116
+ # Returns a serializable update object which is representation of a
117
+ # current Awareness state. Unlike [Y::Awareness#update], this method
118
+ # variant allows to prepare update only for a subset of known clients.
119
+ # These clients must all be known to a current Awareness instance,
120
+ # otherwise an error will be returned.
121
+ #
122
+ # @param [Array<Integer>]
123
+ # @return [Y::AwarenessUpdate] The update object
124
+
125
+ # rubocop:enable Lint/UselessAccessModifier
126
+ end
127
+
128
+ # rubocop:disable Lint/UselessAccessModifier
129
+ class AwarenessEvent
130
+ private
131
+
132
+ # @!method added
133
+ # @return [Array<Integer>] Added clients
134
+
135
+ # @!method updated
136
+ # @return [Array<Integer>] Updated clients
137
+
138
+ # @!method removed
139
+ # @return [Array<Integer>] Removed clients
140
+ end
141
+ # rubocop:enable Lint/UselessAccessModifier
142
+
143
+ # rubocop:disable Lint/UselessAccessModifier
144
+ class AwarenessUpdate
145
+ def encode
146
+ yawareness_update_encode
147
+ end
148
+
149
+ private
150
+
151
+ # @!method yawareness_update_encode
152
+ # Encode the awareness state for simple transport
153
+ #
154
+ # @return [Array<Integer>] Encoded update
155
+ end
156
+ # rubocop:enable Lint/UselessAccessModifier
157
+ end
data/lib/y/doc.rb CHANGED
@@ -113,7 +113,7 @@ module Y
113
113
  # @return [Y::XMLElement]
114
114
  def get_xml_element(name)
115
115
  xml_element = current_transaction.get_xml_element(name)
116
- xml_element.document = self
116
+ xml_element&.document = self
117
117
  xml_element
118
118
  end
119
119
 
data/lib/y/map.rb CHANGED
@@ -18,6 +18,8 @@ module Y
18
18
  # map[:hello] = "world"
19
19
  # puts map[:hello]
20
20
  class Map
21
+ include Enumerable
22
+
21
23
  # @!attribute [r] document
22
24
  #
23
25
  # @return [Y::Doc] The document this map belongs to
data/lib/y/text.rb CHANGED
@@ -115,7 +115,7 @@ module Y
115
115
  # - Hash (where the the types of key and values must be supported)
116
116
  #
117
117
  # @param [Integer] index
118
- # @param [String, Float, Array, Hash] value
118
+ # @param [String, Numeric, Array, Hash] value
119
119
  # @param [Hash|nil] attrs
120
120
  # @return [void]
121
121
  def insert(index, value, attrs = nil)