Class: Hecks::Router::NamespaceInstaller::OptionsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/hecks/router/namespace_installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(router:, realm:, domain:, aggregate:, options:) ⇒ OptionsProxy

Returns a new instance of OptionsProxy.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/hecks/router/namespace_installer.rb', line 11

def initialize(router:, realm:, domain:, aggregate:, options:)
  unknown = options.keys - [:version]
  raise ArgumentError, "unknown router options: #{unknown.join(', ')}" unless unknown.empty?

  @router, @realm, @domain, @aggregate = router, realm, domain, aggregate
  @version = options[:version]&.to_s
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(verb, **args) ⇒ Object



19
20
21
22
# File 'lib/hecks/router/namespace_installer.rb', line 19

def method_missing(verb, **args)
  fqn = fqn_for(verb)
  fqn.command? ? @router.dispatch(fqn.to_s, **args) : @router.query(fqn.to_s, **args)
end

Instance Method Details

#respond_to_missing?(verb, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hecks/router/namespace_installer.rb', line 24

def respond_to_missing?(verb, include_private = false)
  Fqn.command_name?(verb) || Fqn.query_name?(verb) || super
end