Module: SlackChatter::Api::Namespaces

Extended by:
Namespaces
Included in:
Namespaces, Client
Defined in:
lib/slack_chatter/api/namespaces.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/slack_chatter/api/namespaces.rb', line 21

def method_missing(method, *args, &block)
  return super method, *args, &block unless allowed_namespaces.include?(method.to_s)
  self.class.send(:define_method, method) do
    method_sym = "@#{method}".to_sym
    self.instance_variable_get(method_sym) ||
      self.instance_variable_set(method_sym, "SlackChatter::Api::#{method.capitalize}".constantize.new(self))
  end
  self.send method, *args, &block
end