Class: FreshdeskApiclient::REST::ModelFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/freshdesk_apiclient/rest/model_factory.rb

Instance Method Summary collapse

Instance Method Details

#ancestorObject



17
18
19
20
21
# File 'lib/freshdesk_apiclient/rest/model_factory.rb', line 17

def ancestor
  c = Object
  namespace_as_array.each {|m| c = c.const_get m }
  c
end

#instantiate(class_name, *args) ⇒ Object



9
10
11
# File 'lib/freshdesk_apiclient/rest/model_factory.rb', line 9

def instantiate(class_name, *args)
  klass(class_name).new(*args)
end

#klass(class_name) ⇒ Object



13
14
15
# File 'lib/freshdesk_apiclient/rest/model_factory.rb', line 13

def klass(class_name)
  ancestor.const_get class_name
end