S
Sebastia
I have a sorted array (in this case, an ActiveRecord result set) that i
want to give awareness of its sorting state. I defined a singelton
method on the array but i can't figure out how to insert a value from
the surrounding scope. Below is the best i could come up with, but it
seems quite horrid (and using plain eval would be even worse i
suppose). I seem to remember that there was a better way... Anybody?
Thanks,
Sebastian
sort_term = "label"
results = User.findall, rder => sort_term)
class << results
def sorted_by?
@sorted_by_term
end
end
results.instance_variable_set("@sorted_by_term",sort_term)
want to give awareness of its sorting state. I defined a singelton
method on the array but i can't figure out how to insert a value from
the surrounding scope. Below is the best i could come up with, but it
seems quite horrid (and using plain eval would be even worse i
suppose). I seem to remember that there was a better way... Anybody?
Thanks,
Sebastian
sort_term = "label"
results = User.findall, rder => sort_term)
class << results
def sorted_by?
@sorted_by_term
end
end
results.instance_variable_set("@sorted_by_term",sort_term)