Class: Reflect::Reflector

Inherits:
Object
  • Object
show all
Defined in:
lib/reflector.rb

Instance Method Summary collapse

Instance Method Details

#reflect(klass, method, attributes, args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/reflector.rb', line 3

def reflect(klass, method, attributes, args)
  if attributes.nil?
    @instance = Object.const_get(klass).new
  else
    @instance = Object.const_get(klass).new(attributes)
  end
  if Object.const_get(klass).respond_to?(method) # class method
    Object.const_get(klass).send(method, *args)
  else
    @instance.send(method, *args)
  end
end