Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/netzke/core/ruby_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#netzke_deep_map(&block) ⇒ Object



2
3
4
# File 'lib/netzke/core/ruby_ext/array.rb', line 2

def netzke_deep_map(&block)
  self.map{ |el| el.respond_to?(:netzke_deep_map) ? block.call(el.netzke_deep_map(&block)) : block.call(el) }.compact
end

#netzke_deep_replace(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/netzke/core/ruby_ext/array.rb', line 6

def netzke_deep_replace(&block)
  self.map do |el|
    res = yield(el)
    if res == el
      el.respond_to?(:netzke_deep_replace) ? el.netzke_deep_replace(&block) : el
      # el.respond_to?(:netzke_deep_replace) ? block.call(el.netzke_deep_replace(&block)) : block.call(el)
    else
      res
    end
  end.compact
end

#netzke_jsonifyObject



18
19
20
# File 'lib/netzke/core/ruby_ext/array.rb', line 18

def netzke_jsonify
  self.map{ |el| el.is_a?(Array) || el.is_a?(Hash) ? el.netzke_jsonify : el }
end