Class: QML::ProcAccess

Inherits:
Object
  • Object
show all
Includes:
Access
Defined in:
lib/qml/proc_access.rb

Constant Summary

Constants included from Access

Access::ALLOWED_PATTERN

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Access

#to_qml

Methods included from Access::ClassMethods

#meta_class, #register_to_qml, #register_to_qml_impl

Methods included from Reactive

#initialize

Methods included from Reactive::ClassMethods

#properties, #property_infos, #signal_infos, #signals

Class Method Details

.wrap_proc(prc) ⇒ QML::JSFunction

Returns:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/qml/proc_access.rb', line 11

def self.wrap_proc(prc)
  @bind_call ||= QML.engine.evaluate <<-JS
    (function (access) { return access.call.bind(access); })
  JS

  @component ||= QML::Component.new(data: <<-QML)
    import RubyQml 1.0
    ProcAccess {}
  QML

  access = @component.create
  access.unwrap.instance_eval do
    @proc = prc
  end
  @bind_call.call(access)
end

Instance Method Details

#call(args) ⇒ Object


6
7
8
# File 'lib/qml/proc_access.rb', line 6

def call(args)
  @proc.call(*args)
end