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

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/plumber/dispatcher.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.



71
72
73
74
75
76
77
78
79
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 71

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.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def args
  @args
end

#init_argsObject (readonly)

Returns the value of attribute init_args.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def init_args
  @init_args
end

#init_kwargsObject (readonly)

Returns the value of attribute init_kwargs.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def init_kwargs
  @init_kwargs
end

#klassObject (readonly)

Returns the value of attribute klass.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def klass
  @klass
end

#kwargsObject (readonly)

Returns the value of attribute kwargs.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def kwargs
  @kwargs
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



69
70
71
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 69

def method_name
  @method_name
end

Instance Method Details

#call(_target) ⇒ Object



81
82
83
# File 'lib/stimulus_plumbers/components/plumber/dispatcher.rb', line 81

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