Can I write something like this inside model ?
if true
def instance_method
end
def class_method
开发者_StackOverflow社区 end
end
As far as I know if statements do not introduce scope in Ruby 1.9.2 so you can use statements like that
Is this what you desire?
if true
my_object.instance_eval do
def my_instance_method
end
end
my_object.class_eval do
def my_class_eval
end
end
end
you can use also:
if true
class << self
def first_method
end
def second_method
end
end
end
but it would be better when you will post some real code here
精彩评论