Module: Seatbelt::Ghost::ClassMethods

Defined in:
lib/seatbelt/ghost.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Public: Calls a API class method. If the method isn’t defined or found in the class lookup table a Seatbelt::Errors::NoMethodError is raised.

If method is defined it passes the calling responsibility to the core Callee module.

method_name - the called methods name *args - the methods argument list &block - the methods block (this is optional)

Returns the evaluted method value.



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/seatbelt/ghost.rb', line 97

def method_missing(method_name, *args, &block)
  unless self.lookup_tbl.has?(method_name, scope: :class)
    raise Seatbelt::Errors::NoMethodError
  end
  Seatbelt::Callee.handle(self,
                          { :lookup_tbl  => self.lookup_tbl,
                            :scope       => :class,
                            :method_name => method_name
                          },
                          *args,
                          &block)
end