On 9/28/07, Arfon Smith <arfon.smith / gmail.com> wrote:
> I want to have a generic 'find' method that can check to see if an
> object's attribute is true or false.
>
> Basically I want to pass the method name (param) to the list_by_param
> method but this doesn't seem to be working (I get an undefined local
> variable or method 'param' for main:Object) error.


class Object
  def objid_if_param(param)
    "#{self.__id__}" if self.__send__(param) == true
  end
end

class Foo
  attr_accessor :foo
end

bar = Foo.new
baz = Foo.new
baz.foo = true

[ bar, baz ].each do |ob|
  id = ob.objid_if_param(:foo)
  puts id if id
end

-austin
-- 
Austin Ziegler * halostatue / gmail.com * http://www.halostatue.ca/
               * austin / halostatue.ca * http://www.halostatue.ca/feed/
               * austin / zieglers.ca