Module: ObservableObject::DeepWrap
- Defined in:
- lib/observable_object.rb
Constant Summary collapse
- NonWrappable =
[Symbol, Numeric, TrueClass, FalseClass, NilClass]
Class Method Summary collapse
Class Method Details
.is_unwrappable(elem) ⇒ Object
25 26 27 |
# File 'lib/observable_object.rb', line 25 def self.is_unwrappable(elem) NonWrappable.any? { |t| elem.is_a?(t) } end |
.map_obj(obj, notifier) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/observable_object.rb', line 15 def self.map_obj(obj,notifier) case obj when Array then obj.map { |x| wrap_elem(x,notifier) } when Set then obj.clone.map! { |x| wrap_elem(x,notifier) } when Hash then obj.map { |k,v| [ k, wrap_elem(v,notifier) ] }.to_h else obj end end |