y-rb 0.6.0-aarch64-linux-gnu → 0.7.0-aarch64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/yrb/src/ymap.rs CHANGED
@@ -2,7 +2,7 @@ use crate::utils::{convert_yvalue_to_ruby_value, indifferent_hash_key};
2
2
  use crate::yvalue::YValue;
3
3
  use crate::YTransaction;
4
4
  use magnus::block::Proc;
5
- use magnus::{exception, Error, RArray, RHash, Symbol, Value};
5
+ use magnus::{Error, RArray, RHash, Ruby, Value};
6
6
  use std::cell::RefCell;
7
7
  use yrs::types::{EntryChange, Value as YrsValue};
8
8
  use yrs::{Any, Map, MapRef, Observable};
@@ -56,12 +56,13 @@ impl YMap {
56
56
  key: Value,
57
57
  value: Value,
58
58
  ) -> Result<(), Error> {
59
+ let ruby = Ruby::get().unwrap();
59
60
  let mut tx = transaction.transaction();
60
61
  let tx = tx.as_mut().unwrap();
61
62
 
62
63
  match indifferent_hash_key(key) {
63
64
  None => Err(Error::new(
64
- exception::runtime_error(),
65
+ ruby.exception_runtime_error(),
65
66
  "invalid key type, make sure it is either of type Symbol or String",
66
67
  )),
67
68
  Some(k) => {
@@ -73,23 +74,25 @@ impl YMap {
73
74
  }
74
75
  }
75
76
  pub(crate) fn ymap_observe(&self, block: Proc) -> u32 {
76
- let change_inserted = Symbol::new("inserted").as_static();
77
- let change_updated = Symbol::new("updated").as_static();
78
- let change_removed = Symbol::new("removed").as_static();
77
+ let ruby = unsafe { Ruby::get_unchecked() };
78
+ let change_inserted = ruby.to_symbol("inserted").as_static();
79
+ let change_updated = ruby.to_symbol("updated").as_static();
80
+ let change_removed = ruby.to_symbol("removed").as_static();
79
81
  self.0
80
82
  .borrow_mut()
81
83
  .observe(move |transaction, map_event| {
84
+ let ruby = unsafe { Ruby::get_unchecked() };
82
85
  let delta = map_event.keys(transaction);
83
- let changes = RArray::with_capacity(delta.len());
86
+ let changes = ruby.ary_new_capa(delta.len());
84
87
 
85
88
  for (key, change) in delta {
86
89
  match change {
87
90
  EntryChange::Inserted(v) => {
88
- let h = RHash::new();
89
- h.aset(Symbol::new(key), *YValue::from(v.clone()).0.borrow())
91
+ let h = ruby.hash_new();
92
+ h.aset(ruby.to_symbol(key), *YValue::from(v.clone()).0.borrow())
90
93
  .expect("cannot add change::inserted");
91
94
 
92
- let payload = RHash::new();
95
+ let payload = ruby.hash_new();
93
96
  payload
94
97
  .aset(change_inserted, h)
95
98
  .expect("cannot add change::inserted");
@@ -97,7 +100,7 @@ impl YMap {
97
100
  changes.push(payload).expect("cannot push changes::payload");
98
101
  }
99
102
  EntryChange::Updated(old, new) => {
100
- let values = RArray::with_capacity(2);
103
+ let values = ruby.ary_new_capa(2);
101
104
  values
102
105
  .push(*YValue::from(old.clone()).0.borrow())
103
106
  .expect("cannot push change::updated");
@@ -105,11 +108,11 @@ impl YMap {
105
108
  .push(*YValue::from(new.clone()).0.borrow())
106
109
  .expect("cannot push change::updated");
107
110
 
108
- let h = RHash::new();
109
- h.aset(Symbol::new(key), values)
111
+ let h = ruby.hash_new();
112
+ h.aset(ruby.to_symbol(key), values)
110
113
  .expect("cannot push change::updated");
111
114
 
112
- let payload = RHash::new();
115
+ let payload = ruby.hash_new();
113
116
  payload
114
117
  .aset(change_updated, h)
115
118
  .expect("cannot push change::updated");
@@ -117,11 +120,11 @@ impl YMap {
117
120
  changes.push(payload).expect("cannot push changes::payload");
118
121
  }
119
122
  EntryChange::Removed(v) => {
120
- let h = RHash::new();
121
- h.aset(Symbol::new(key), *YValue::from(v.clone()).0.borrow())
123
+ let h = ruby.hash_new();
124
+ h.aset(ruby.to_symbol(key), *YValue::from(v.clone()).0.borrow())
122
125
  .expect("cannot push change::removed");
123
126
 
124
- let payload = RHash::new();
127
+ let payload = ruby.hash_new();
125
128
  payload
126
129
  .aset(change_removed, h)
127
130
  .expect("cannot push change::removed");
@@ -153,15 +156,17 @@ impl YMap {
153
156
  self.0.borrow().len(tx)
154
157
  }
155
158
  pub(crate) fn ymap_to_h(&self, transaction: &YTransaction) -> RHash {
159
+ let ruby = unsafe { Ruby::get_unchecked() };
156
160
  let tx = transaction.transaction();
157
161
  let tx = tx.as_ref().unwrap();
158
162
 
159
- RHash::from_iter(
160
- self.0
161
- .borrow()
162
- .iter(tx)
163
- .map(move |(k, v)| (k.to_string(), *YValue::from(v).0.borrow())),
164
- )
163
+ let hash = ruby.hash_new();
164
+ for (k, v) in self.0.borrow().iter(tx) {
165
+ let value = *YValue::from(v).0.borrow();
166
+ hash.aset(k.to_string(), value)
167
+ .expect("cannot insert into hash");
168
+ }
169
+ hash
165
170
  }
166
171
  pub(crate) fn ymap_unobserve(&self, subscription_id: u32) {
167
172
  self.0.borrow_mut().unobserve(subscription_id);
data/ext/yrb/src/ytext.rs CHANGED
@@ -5,7 +5,7 @@ use crate::YTransaction;
5
5
  use magnus::block::Proc;
6
6
  use magnus::value::Qnil;
7
7
  use magnus::RArray;
8
- pub(crate) use magnus::{Error, IntoValue, RHash, Symbol, Value};
8
+ pub(crate) use magnus::{Error, IntoValue, RHash, Ruby, Value};
9
9
  use std::cell::RefCell;
10
10
  use yrs::types::text::YChange;
11
11
  use yrs::types::Delta;
@@ -19,36 +19,35 @@ unsafe impl Send for YText {}
19
19
 
20
20
  impl YText {
21
21
  pub(crate) fn ytext_diff(&self, transaction: &YTransaction) -> RArray {
22
+ let ruby = unsafe { Ruby::get_unchecked() };
22
23
  let tx = transaction.transaction();
23
24
  let tx = tx.as_ref().unwrap();
24
25
 
25
- RArray::from_iter(
26
- self.0
27
- .borrow()
28
- .diff(tx, YChange::identity)
29
- .iter()
30
- .map(move |diff| {
31
- let yvalue = YValue::from(diff.insert.clone());
32
- let insert = yvalue.0.into_inner();
33
- let attributes = diff.attributes.as_ref().map_or_else(
34
- || None,
35
- |boxed_attrs| {
36
- let attributes = RHash::new();
37
- for (key, value) in boxed_attrs.iter() {
38
- let key = key.to_string();
39
- let value = YValue::from(value.clone()).0.into_inner();
40
- attributes.aset(key, value).expect("cannot add value");
41
- }
42
- Some(attributes)
43
- },
44
- );
45
- YDiff {
46
- ydiff_insert: insert,
47
- ydiff_attrs: attributes,
26
+ let array = ruby.ary_new();
27
+ for diff in self.0.borrow().diff(tx, YChange::identity).iter() {
28
+ let yvalue = YValue::from(diff.insert.clone());
29
+ let insert = yvalue.0.into_inner();
30
+ let attributes = diff.attributes.as_ref().map_or_else(
31
+ || None,
32
+ |boxed_attrs| {
33
+ let attributes = ruby.hash_new();
34
+ for (key, value) in boxed_attrs.iter() {
35
+ let key = key.to_string();
36
+ let value = YValue::from(value.clone()).0.into_inner();
37
+ attributes.aset(key, value).expect("cannot add value");
48
38
  }
49
- .into_value()
50
- }),
51
- )
39
+ Some(attributes)
40
+ },
41
+ );
42
+ let ydiff = YDiff {
43
+ ydiff_insert: insert,
44
+ ydiff_attrs: attributes,
45
+ };
46
+ array
47
+ .push(ydiff.into_value_with(&ruby))
48
+ .expect("cannot push diff to array");
49
+ }
50
+ array
52
51
  }
53
52
  pub(crate) fn ytext_format(
54
53
  &self,
@@ -128,64 +127,68 @@ impl YText {
128
127
  self.0.borrow().len(tx)
129
128
  }
130
129
  pub(crate) fn ytext_observe(&self, block: Proc) -> Result<u32, Error> {
131
- let delta_insert = Symbol::new("insert").to_static();
132
- let delta_retain = Symbol::new("retain").to_static();
133
- let delta_delete = Symbol::new("delete").to_static();
134
- let attributes = Symbol::new("attributes").to_static();
130
+ let ruby = unsafe { Ruby::get_unchecked() };
131
+ let delta_insert = ruby.to_symbol("insert").to_static();
132
+ let delta_retain = ruby.to_symbol("retain").to_static();
133
+ let delta_delete = ruby.to_symbol("delete").to_static();
134
+ let attributes = ruby.to_symbol("attributes").to_static();
135
135
 
136
136
  // let mut error: Option<Error> = None;
137
137
  let subscription_id = self
138
138
  .0
139
139
  .borrow_mut()
140
140
  .observe(move |transaction, text_event| {
141
+ let ruby = unsafe { Ruby::get_unchecked() };
141
142
  let delta = text_event.delta(transaction);
142
143
  let (_, errors): (Vec<_>, Vec<_>) = delta
143
144
  .iter()
144
145
  .map(|change| match change {
145
146
  Delta::Inserted(value, attrs) => {
146
147
  let yvalue = YValue::from(value.clone());
147
- let payload = RHash::new();
148
+ let payload = ruby.hash_new();
148
149
  payload
149
150
  .aset(delta_insert, yvalue.0.into_inner())
150
151
  .map(|()| match attrs {
151
- Some(a) => a
152
- .clone()
153
- .into_iter()
154
- .map(|(key, val)| {
152
+ Some(a) => {
153
+ let attrs_hash = ruby.hash_new();
154
+ for (key, val) in a.clone().into_iter() {
155
155
  let yvalue = YValue::from(val);
156
- (key.to_string(), yvalue.0.into_inner())
157
- })
158
- .collect::<RHash>()
159
- .into(),
156
+ attrs_hash
157
+ .aset(key.to_string(), yvalue.0.into_inner())
158
+ .expect("cannot add attr");
159
+ }
160
+ Some(attrs_hash)
161
+ }
160
162
  None => None,
161
163
  })
162
164
  .map(|attrs_hash| attrs_hash.map(|v| payload.aset(attributes, v)))
163
165
  .map(|_| block.call::<(RHash,), Qnil>((payload,)))
164
166
  }
165
167
  Delta::Retain(index, attrs) => {
166
- let payload = RHash::new();
168
+ let payload = ruby.hash_new();
167
169
 
168
170
  let yvalue = YValue::from(*index);
169
171
 
170
172
  payload
171
173
  .aset(delta_retain, yvalue.0.into_inner())
172
174
  .map(|()| match attrs {
173
- Some(a) => a
174
- .clone()
175
- .into_iter()
176
- .map(|(key, val)| {
175
+ Some(a) => {
176
+ let attrs_hash = ruby.hash_new();
177
+ for (key, val) in a.clone().into_iter() {
177
178
  let yvalue = YValue::from(val);
178
- (key.to_string(), yvalue.0.into_inner())
179
- })
180
- .collect::<RHash>()
181
- .into(),
179
+ attrs_hash
180
+ .aset(key.to_string(), yvalue.0.into_inner())
181
+ .expect("cannot add attr");
182
+ }
183
+ Some(attrs_hash)
184
+ }
182
185
  None => None,
183
186
  })
184
187
  .map(|attrs_hash| attrs_hash.map(|v| payload.aset(attributes, v)))
185
188
  .map(|_| block.call::<(RHash,), Qnil>((payload,)))
186
189
  }
187
190
  Delta::Deleted(index) => {
188
- let payload = RHash::new();
191
+ let payload = ruby.hash_new();
189
192
 
190
193
  let yvalue = YValue::from(*index);
191
194
 
@@ -4,7 +4,7 @@ use crate::ytext::YText;
4
4
  use crate::yxml_element::YXmlElement;
5
5
  use crate::yxml_fragment::YXmlFragment;
6
6
  use crate::yxml_text::YXmlText;
7
- use magnus::{exception, Error};
7
+ use magnus::{Error, Ruby};
8
8
  use std::cell::{RefCell, RefMut};
9
9
  use yrs::updates::decoder::Decode;
10
10
  use yrs::updates::encoder::Encode;
@@ -28,10 +28,11 @@ impl<'doc> From<TransactionMut<'doc>> for YTransaction {
28
28
  // API which is eventually publicly exposed
29
29
  impl YTransaction {
30
30
  pub(crate) fn ytransaction_apply_update(&self, update: Vec<u8>) -> Result<(), Error> {
31
+ let ruby = Ruby::get().unwrap();
31
32
  Update::decode_v1(update.as_slice())
32
33
  .map_err(|error| {
33
34
  Error::new(
34
- exception::runtime_error(),
35
+ ruby.exception_runtime_error(),
35
36
  format!("cannot decode update: {:?}", error),
36
37
  )
37
38
  })
@@ -39,10 +40,11 @@ impl YTransaction {
39
40
  }
40
41
 
41
42
  pub(crate) fn ytransaction_apply_update_v2(&self, update: Vec<u8>) -> Result<(), Error> {
43
+ let ruby = Ruby::get().unwrap();
42
44
  Update::decode_v2(update.as_slice())
43
45
  .map_err(|error| {
44
46
  Error::new(
45
- exception::runtime_error(),
47
+ ruby.exception_runtime_error(),
46
48
  format!("cannot decode update: {:?}", error),
47
49
  )
48
50
  })
@@ -1,7 +1,7 @@
1
1
  use crate::{YText, YXmlElement, YXmlText};
2
2
  use magnus::r_hash::ForEach::Continue;
3
3
  use magnus::value::{Qnil, ReprValue};
4
- use magnus::{class, value, Float, Integer, IntoValue, RArray, RHash, RString, Symbol, Value};
4
+ use magnus::{Float, Integer, IntoValue, RArray, RHash, RString, Ruby, Symbol, Value};
5
5
  use std::cell::RefCell;
6
6
  use std::collections::HashMap;
7
7
  use std::sync::Arc;
@@ -21,108 +21,128 @@ impl From<Value> for YValue {
21
21
 
22
22
  impl From<Qnil> for YValue {
23
23
  fn from(value: Qnil) -> Self {
24
- YValue(RefCell::from(value.into_value()))
24
+ let ruby = unsafe { Ruby::get_unchecked() };
25
+ YValue(RefCell::from(value.into_value_with(&ruby)))
25
26
  }
26
27
  }
27
28
 
28
29
  impl From<bool> for YValue {
29
30
  fn from(value: bool) -> Self {
30
- YValue(RefCell::from(value.into_value()))
31
+ let ruby = unsafe { Ruby::get_unchecked() };
32
+ YValue(RefCell::from(value.into_value_with(&ruby)))
31
33
  }
32
34
  }
33
35
 
34
36
  impl From<f64> for YValue {
35
37
  fn from(value: f64) -> Self {
36
- YValue(RefCell::from(value.into_value()))
38
+ let ruby = unsafe { Ruby::get_unchecked() };
39
+ YValue(RefCell::from(value.into_value_with(&ruby)))
37
40
  }
38
41
  }
39
42
 
40
43
  impl From<i64> for YValue {
41
44
  fn from(value: i64) -> Self {
42
- YValue(RefCell::from(value.into_value()))
45
+ let ruby = unsafe { Ruby::get_unchecked() };
46
+ YValue(RefCell::from(value.into_value_with(&ruby)))
43
47
  }
44
48
  }
45
49
 
46
50
  impl From<u32> for YValue {
47
51
  fn from(value: u32) -> Self {
48
- YValue(RefCell::from(value.into_value()))
52
+ let ruby = unsafe { Ruby::get_unchecked() };
53
+ YValue(RefCell::from(value.into_value_with(&ruby)))
49
54
  }
50
55
  }
51
56
 
52
57
  impl From<String> for YValue {
53
58
  fn from(value: String) -> Self {
54
- YValue(RefCell::from(value.into_value()))
59
+ let ruby = unsafe { Ruby::get_unchecked() };
60
+ YValue(RefCell::from(value.into_value_with(&ruby)))
55
61
  }
56
62
  }
57
63
 
58
64
  impl From<RArray> for YValue {
59
65
  fn from(value: RArray) -> Self {
60
- YValue(RefCell::from(value.into_value()))
66
+ let ruby = unsafe { Ruby::get_unchecked() };
67
+ YValue(RefCell::from(value.into_value_with(&ruby)))
61
68
  }
62
69
  }
63
70
 
64
71
  impl From<RHash> for YValue {
65
72
  fn from(value: RHash) -> Self {
66
- YValue(RefCell::from(value.into_value()))
73
+ let ruby = unsafe { Ruby::get_unchecked() };
74
+ YValue(RefCell::from(value.into_value_with(&ruby)))
67
75
  }
68
76
  }
69
77
 
70
78
  impl From<Vec<u8>> for YValue {
71
79
  fn from(value: Vec<u8>) -> Self {
72
- YValue(RefCell::from(value.into_value()))
80
+ let ruby = unsafe { Ruby::get_unchecked() };
81
+ YValue(RefCell::from(value.into_value_with(&ruby)))
73
82
  }
74
83
  }
75
84
 
76
85
  impl From<YrsText> for YValue {
77
86
  fn from(value: YrsText) -> Self {
78
- YValue(RefCell::from(YText(RefCell::from(value)).into_value()))
87
+ let ruby = unsafe { Ruby::get_unchecked() };
88
+ YValue(RefCell::from(
89
+ YText(RefCell::from(value)).into_value_with(&ruby),
90
+ ))
79
91
  }
80
92
  }
81
93
 
82
94
  impl From<YrsXmlElement> for YValue {
83
95
  fn from(value: YrsXmlElement) -> Self {
96
+ let ruby = unsafe { Ruby::get_unchecked() };
84
97
  YValue(RefCell::from(
85
- YXmlElement(RefCell::from(value)).into_value(),
98
+ YXmlElement(RefCell::from(value)).into_value_with(&ruby),
86
99
  ))
87
100
  }
88
101
  }
89
102
 
90
103
  impl From<YrsXmlText> for YValue {
91
104
  fn from(value: YrsXmlText) -> Self {
92
- YValue(RefCell::from(YXmlText(RefCell::from(value)).into_value()))
105
+ let ruby = unsafe { Ruby::get_unchecked() };
106
+ YValue(RefCell::from(
107
+ YXmlText(RefCell::from(value)).into_value_with(&ruby),
108
+ ))
93
109
  }
94
110
  }
95
111
 
96
112
  impl From<YText> for YValue {
97
113
  fn from(value: YText) -> Self {
98
- YValue(RefCell::from(value.into_value()))
114
+ let ruby = unsafe { Ruby::get_unchecked() };
115
+ YValue(RefCell::from(value.into_value_with(&ruby)))
99
116
  }
100
117
  }
101
118
 
102
119
  impl From<YXmlElement> for YValue {
103
120
  fn from(value: YXmlElement) -> Self {
104
- YValue(RefCell::from(value.into_value()))
121
+ let ruby = unsafe { Ruby::get_unchecked() };
122
+ YValue(RefCell::from(value.into_value_with(&ruby)))
105
123
  }
106
124
  }
107
125
 
108
126
  impl From<YXmlText> for YValue {
109
127
  fn from(value: YXmlText) -> Self {
110
- YValue(RefCell::from(value.into_value()))
128
+ let ruby = unsafe { Ruby::get_unchecked() };
129
+ YValue(RefCell::from(value.into_value_with(&ruby)))
111
130
  }
112
131
  }
113
132
 
114
133
  impl From<Any> for YValue {
115
134
  fn from(value: Any) -> Self {
135
+ let ruby = unsafe { Ruby::get_unchecked() };
116
136
  match value {
117
- Any::Null => YValue::from(value::qnil()),
118
- Any::Undefined => YValue::from(value::qnil()),
137
+ Any::Null => YValue::from(ruby.qnil()),
138
+ Any::Undefined => YValue::from(ruby.qnil()),
119
139
  Any::Bool(v) => YValue::from(v),
120
140
  Any::Number(v) => YValue::from(v),
121
141
  Any::BigInt(v) => YValue::from(v),
122
142
  Any::String(v) => YValue::from(v.to_string()),
123
143
  Any::Buffer(v) => YValue::from(v.to_vec()),
124
144
  Any::Array(v) => {
125
- let arr = RArray::new();
145
+ let arr = ruby.ary_new();
126
146
  for item in v.iter() {
127
147
  let val = YValue::from(item.clone());
128
148
  let val = *val.0.borrow();
@@ -131,14 +151,14 @@ impl From<Any> for YValue {
131
151
  YValue::from(arr)
132
152
  }
133
153
  Any::Map(v) => {
134
- let map = v
135
- .iter()
136
- .map(|(key, val)| {
137
- let v = val.clone();
138
- (key.to_string(), YValue::from(v).into())
139
- })
140
- .collect::<HashMap<String, Value>>();
141
- YValue::from(RHash::from_iter(map))
154
+ let hash = ruby.hash_new();
155
+ for (key, val) in v.iter() {
156
+ let v = val.clone();
157
+ let value: Value = YValue::from(v).into();
158
+ hash.aset(key.to_string(), value)
159
+ .expect("cannot insert into hash");
160
+ }
161
+ YValue::from(hash)
142
162
  }
143
163
  }
144
164
  }
@@ -146,6 +166,7 @@ impl From<Any> for YValue {
146
166
 
147
167
  impl From<YrsValue> for YValue {
148
168
  fn from(value: YrsValue) -> Self {
169
+ let ruby = unsafe { Ruby::get_unchecked() };
149
170
  match value {
150
171
  YrsValue::Any(val) => YValue::from(val),
151
172
  YrsValue::YText(text) => YValue::from(text),
@@ -153,7 +174,7 @@ impl From<YrsValue> for YValue {
153
174
  YrsValue::YXmlText(text) => YValue::from(text),
154
175
  YrsValue::YArray(val) => {
155
176
  let tx = val.transact();
156
- let arr = RArray::new();
177
+ let arr = ruby.ary_new();
157
178
  for item in val.iter(&tx) {
158
179
  let val = YValue::from(item.clone());
159
180
  let val = *val.0.borrow();
@@ -163,12 +184,13 @@ impl From<YrsValue> for YValue {
163
184
  }
164
185
  YrsValue::YMap(val) => {
165
186
  let tx = val.transact();
166
- let iter = val.iter(&tx).map(|(key, val)| {
167
- let val = YValue::from(val);
187
+ let hash = ruby.hash_new();
188
+ for (key, value) in val.iter(&tx) {
189
+ let val = YValue::from(value);
168
190
  let val = val.0.into_inner();
169
- (key, val)
170
- });
171
- YValue::from(RHash::from_iter(iter))
191
+ hash.aset(key, val).expect("cannot insert into hash");
192
+ }
193
+ YValue::from(hash)
172
194
  }
173
195
  v => panic!("cannot map complex yrs values to yvalue: {:?}", v),
174
196
  }
@@ -177,36 +199,37 @@ impl From<YrsValue> for YValue {
177
199
 
178
200
  impl From<YValue> for Any {
179
201
  fn from(val: YValue) -> Self {
202
+ let ruby = unsafe { Ruby::get_unchecked() };
180
203
  let value = val.0.into_inner();
181
204
  if value.is_nil() {
182
205
  Any::Null
183
- } else if value.is_kind_of(class::float()) {
206
+ } else if value.is_kind_of(ruby.class_float()) {
184
207
  let f = Float::from_value(value).unwrap();
185
208
  Any::Number(f.to_f64())
186
- } else if value.is_kind_of(class::integer()) {
209
+ } else if value.is_kind_of(ruby.class_integer()) {
187
210
  let i = Integer::from_value(value).unwrap();
188
211
  Any::BigInt(i.to_i64().unwrap())
189
- } else if value.is_kind_of(class::symbol()) {
212
+ } else if value.is_kind_of(ruby.class_symbol()) {
190
213
  let s = Symbol::from_value(value).unwrap();
191
214
  Any::String(Arc::from(s.name().unwrap()))
192
- } else if value.is_kind_of(class::true_class()) {
215
+ } else if value.is_kind_of(ruby.class_true_class()) {
193
216
  Any::Bool(true)
194
- } else if value.is_kind_of(class::false_class()) {
217
+ } else if value.is_kind_of(ruby.class_false_class()) {
195
218
  Any::Bool(false)
196
- } else if value.is_kind_of(class::string()) {
219
+ } else if value.is_kind_of(ruby.class_string()) {
197
220
  let s = RString::from_value(value).unwrap();
198
221
  unsafe { Any::String(Arc::from(s.as_str().unwrap().to_string())) }
199
- } else if value.is_kind_of(class::array()) {
222
+ } else if value.is_kind_of(ruby.class_array()) {
200
223
  let arr = RArray::from_value(value).unwrap();
201
224
  let items = arr
202
- .each()
225
+ .into_iter()
203
226
  .map(|item| {
204
- let yvalue = YValue::from(item.unwrap());
227
+ let yvalue = YValue::from(item);
205
228
  Any::from(yvalue)
206
229
  })
207
230
  .collect::<Vec<Any>>();
208
231
  Any::Array(Arc::from(items))
209
- } else if value.is_kind_of(class::hash()) {
232
+ } else if value.is_kind_of(ruby.class_hash()) {
210
233
  let map = RHash::from_value(value).unwrap();
211
234
  let mut m: HashMap<String, Any> = HashMap::new();
212
235