Class: Rhelm::Client::SubcommandProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rhelm/subcommand_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(subcommand_name, client, *args, **kwargs) ⇒ SubcommandProxy

Returns a new instance of SubcommandProxy.



6
7
8
9
10
11
12
13
14
# File 'lib/rhelm/subcommand_proxy.rb', line 6

def initialize(subcommand_name, client, *args, **kwargs)
  unless SUBCOMMANDS.include?(subcommand_name.to_sym)
    raise(Error, "Unknown subcommand #{subcommand_name}")
  end

  kwargs[:client] ||= client
  class_name = "::Rhelm::Subcommand::#{subcommand_name.to_s.capitalize}"
  @subcommand = Object.const_get(class_name).new(*args, **kwargs)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, **kwargs, &block) ⇒ Object



16
17
18
# File 'lib/rhelm/subcommand_proxy.rb', line 16

def method_missing(m, *args, **kwargs, &block)
  @subcommand.send m, *args, **kwargs, &block
end