Method: Github::API.namespace
- Defined in:
- lib/github_api2/api.rb
.namespace(*names) ⇒ self
Defines a namespace
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/github_api2/api.rb', line 322 def self.namespace(*names) = names.last.is_a?(Hash) ? names.pop : {} names = names.map(&:to_sym) name = names.pop if public_method_defined?(name) raise ArgumentError, "namespace '#{name}' is already defined" end class_name = extract_class_name(name, ) define_method(name) do |*args, &block| = args.last.is_a?(Hash) ? args.pop : {} API::Factory.new(class_name, .merge(), &block) end end |