Class: Object

Inherits:
BasicObject
Defined in:
lib/can_has_meta/core_ext/object.rb

Instance Method Summary collapse

Instance Method Details

#instance_eval_with_args(*args, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/can_has_meta/core_ext/object.rb', line 17

def instance_eval_with_args(*args, &block)
  while respond_to?(random_name = "temp_method#{rand(1000)}"); end
  
  klass.class_eval do
    define_method(random_name, &block)
  end
  
  self.send(random_name, *args)
  
  klass.class_eval("undef #{random_name}")
end

#instance_eval_with_args_check(*args, &block) ⇒ Object Also known as: instance_eval



6
7
8
9
10
11
12
# File 'lib/can_has_meta/core_ext/object.rb', line 6

def instance_eval_with_args_check(*args, &block)
  unless args.empty? || block.nil?
    instance_eval_with_args(*args, &block)
  else
    instance_eval_without_args_check(*args, &block)
  end
end

#klassObject



2
3
4
# File 'lib/can_has_meta/core_ext/object.rb', line 2

def klass
  self.class
end