From: Michael Fellinger Date: 2009-03-02T19:54:41+09:00 Subject: Re: passing a method as a paramter On Mon, Mar 2, 2009 at 7:44 PM, Sarah Allen wrote: > Wow.  Awesome run through of various Ruby syntax options -- I think I'll > print that out and hang it on my wall.  Oddly none of those match the > original definition which uses send but has just a single > "creation_method" parameter... > >>>  #  assert_required_fields :create_article, :subject, :body, :author >>>  def assert_required_fields(creation_method, *field_names) >>>    field_names.each do |field| >>>      record = send(creation_method, field => nil) >>>      assert_equal false, record.valid? >>>      assert_not_nil record.errors.on(field) >>>    end >>>  end > > Any thoughts on how that could be called? It's the second example, you cannot obtain an instance of Method like you would do in Python or JavaScript by simply omitting the parenthesis, you have to use the Object#method method. All of these are equivalent: User.create User.create() User.method(:create).call User.send(:create) ^ manveru > Thanks, > Sarah > -- > Posted via http://www.ruby-forum.com/. > >