Module: Native::Helpers
- Defined in:
- opal/stdlib/native.rb
Instance Method Summary collapse
- #alias_native(new, old = new, options = {}) ⇒ Object
- #native_accessor(*names) ⇒ Object
- #native_reader(*names) ⇒ Object
- #native_writer(*names) ⇒ Object
Instance Method Details
#alias_native(new, old = new, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'opal/stdlib/native.rb', line 68 def alias_native(new, old = new, = {}) if old.end_with? ?= define_method new do |value| `#@native[#{old[0 .. -2]}] = #{Native.convert(value)}` value 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 |
#native_accessor(*names) ⇒ Object
106 107 108 109 |
# File 'opal/stdlib/native.rb', line 106 def native_accessor(*names) native_reader(*names) native_writer(*names) end |