Method: Zcloudjp::Client#method_missing

Defined in:
lib/zcloudjp/client.rb

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

Defines the method if not defined yet.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zcloudjp/client.rb', line 33

def method_missing(method, *args, &block)
  self.class.class_eval do
    attr_accessor method.to_sym

    # Defined a method according to the given method name
    define_method method.to_sym do
      obj = OpenStruct.new(request_options: @request_options)
      obj.extend Zcloudjp.const_get(method.capitalize.to_sym)
      instance_variable_set(:"@#{method}", obj)
    end
  end

  # Sends to the now-defined method.
  self.__send__(method.to_sym)
end