Class: QML::Reactive::UnboundSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/qml/reactive/unbound_signal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params, variadic, owner, factory = nil) ⇒ UnboundSignal

Returns a new instance of UnboundSignal.



8
9
10
11
12
13
14
15
# File 'lib/qml/reactive/unbound_signal.rb', line 8

def initialize(name, params, variadic, owner, factory = nil)
  @name = name
  @params = params
  @variadic = variadic
  @owner = owner
  @factory = factory
  @original = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#originalObject (readonly)

Returns the value of attribute original.



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

def original
  @original
end

#ownerObject (readonly)

Returns the value of attribute owner.



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

def owner
  @owner
end

Instance Method Details

#alias(name) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/qml/reactive/unbound_signal.rb', line 17

def alias(name)
  dup.tap do |signal|
    signal.instance_eval do
      @name = name
    end
  end
end

#alias?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/qml/reactive/unbound_signal.rb', line 29

def alias?
  @original != @name
end

#arityObject



33
34
35
# File 'lib/qml/reactive/unbound_signal.rb', line 33

def arity
  @params ? @params.size : -1
end

#bind(obj) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/qml/reactive/unbound_signal.rb', line 41

def bind(obj)
  return obj.instance_exec(&@factory) if @factory
  if @variadic
    Signal.new(nil)
  else
    Signal.new(@params)
  end
end

#parametersObject



37
38
39
# File 'lib/qml/reactive/unbound_signal.rb', line 37

def parameters
  @params ? @params.map { |arg| [:req, arg] } : [[:rest, :args]]
end

#variadic?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/qml/reactive/unbound_signal.rb', line 25

def variadic?
  @variadic
end