Class: StimulusPlumbers::Plumber::Dispatcher::KlassProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, method_name, *args, init_args: [], init_kwargs: {}, **kwargs) ⇒ KlassProxy

Returns a new instance of KlassProxy.



9
10
11
12
13
14
15
16
17
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 9

def initialize(klass, method_name, *args, init_args: [], init_kwargs: {}, **kwargs)
  @klass       = klass
  @method_name = method_name
  @args        = args
  @kwargs      = kwargs
  @init_args   = init_args
  @init_kwargs = init_kwargs
  validate!
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def args
  @args
end

#init_argsObject (readonly)

Returns the value of attribute init_args.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def init_args
  @init_args
end

#init_kwargsObject (readonly)

Returns the value of attribute init_kwargs.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def init_kwargs
  @init_kwargs
end

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def klass
  @klass
end

#kwargsObject (readonly)

Returns the value of attribute kwargs.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def kwargs
  @kwargs
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



7
8
9
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 7

def method_name
  @method_name
end

Instance Method Details

#call(_target) ⇒ Object



19
20
21
# File 'lib/stimulus_plumbers/plumber/dispatcher/klass_proxy.rb', line 19

def call(_target)
  klass.new(*init_args, **init_kwargs).public_send(method_name, *args, **kwargs)
end