Class: TelphinApi::Namespace

Inherits:
Object
  • Object
show all
Includes:
Resolvable, Resolver
Defined in:
lib/telphin_api/namespace.rb

Overview

An API method namespace (such as extensions or phone_calls).

It includes Resolvable and Resolver and calls API methods via Resolver#call_method. It also holds the list of all known namespaces.

Instance Attribute Summary

Attributes included from Resolvable

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resolver

included, #resolver

Methods included from Resolvable

#initialize, #token

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object

Creates and calls the TelphinApi::Method using TelphinApi::Resolver#call_method.



11
12
13
# File 'lib/telphin_api/namespace.rb', line 11

def method_missing(*args, &block)
  call_method(args, &block)
end

Class Method Details

.exists?(name) ⇒ Boolean

Does a given namespace exist?

Parameters:

  • name (String, Symbol)

Returns:

  • (Boolean)


31
32
33
# File 'lib/telphin_api/namespace.rb', line 31

def exists?(name)
  names.include?(name.to_s)
end

.namesArray

An array of all method namespaces.

Lazily loads the list from namespaces.yml and caches it.

Returns:

  • (Array)

    An array of strings



20
21
22
23
24
25
26
27
# File 'lib/telphin_api/namespace.rb', line 20

def names
  if @names.nil?
    filename = File.expand_path('../namespaces.yml', __FILE__)
    @names   = YAML.load_file(filename)
  end
  
  @names
end