Module: Highcharts::NativePatches
- Extended by:
- Native::Helpers
- Defined in:
- lib/opal/highcharts/base.rb
Instance Method Summary collapse
-
#alias_native(new, old = new, options = {}) ⇒ Object
Patch of Native.alias_native to provide us with ability to specify: alias_native :ruby_name, :js_name, as_array_of: Class which will map the elements of the native array to elements type Class.
Instance Method Details
#alias_native(new, old = new, options = {}) ⇒ Object
Patch of Native.alias_native to provide us with ability to specify:
alias_native :ruby_name, :js_name, as_array_of: Class
which will map the elements of the native array to elements type Class.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/opal/highcharts/base.rb', line 22 def alias_native(new, old = new, = {}) if old.end_with? ?= define_method new do |value| `console.log(#{"#{__FILE__}[#{__LINE__}]"})` `#@native[#{old[0 .. -2]}] = #{Native.convert(value)}` value end elsif as = [:as_array_of] define_method new do |*args, &block| if value = Native.call(@native, old, *args, &block) value.map { |e| as.new(e.to_n) } end end else if as = [:as] define_method new do |*args, &block| if value = Native.call(@native, old, *args, &block) as.new(value.to_n) end end else define_method new do |*args, &block| Native.call(@native, old, *args, &block) end end end end |