search for: my_method

Displaying 20 results from an estimated 38 matches for "my_method".

2013 Nov 29
1
How to catch warnings sent by arguments of s4 methods ?
Hello, I apologized if this had already been addressed, and I also submitted this problem on SO: http://stackoverflow.com/questions/20268021/how-to-catch-warnings-sent-during-s4-method-selection Example code: setGeneric('my_method', function(x) standardGeneric('my_method') ) setMethod('my_method', 'ANY', function(x) invisible()) withCallingHandlers(my_method(warning('argh')), warning = function(w) { stop('got warning:', w) }) # this does not catch the warning It seems that the wa...
2008 Apr 04
5
First call to worker method doesn''t work
I have a worker as follows: class SampleWorker < BackgrounDRb::MetaWorker set_worker_name :sample_worker def create(args = nil) # this method is called, when worker is loaded for the first time end def my_method # Deliver test e-mail message Notifications.deliver_message(1, "DM") end end I have a rails controller that calls the following code: worker = MiddleMan.worker(:sample_worker) worker.my_method The problem is that the first time I load up the page for this action, the...
2006 Dec 02
3
Scoping expectations and more ...
Hello! I''m new to Mocha and through experimentation I found out something that is not explicitly stated in the documentation: If you need to mock the same function call with different parameters and results, you can set the scope of expectations with a begin ... end block. I also made up an example on how to expect more than one function call with different parameters and return values.
2006 Jun 17
1
magic disappearing parameters
I have a method in application_helper.rb like this: def my_method(arg1, arg2 = {}) ... end when I call this method from an rhtml file like this: my_method @var I get this message: wrong number of arguments (1 for 0) When I call the method without arguments like this: my_method I get this message: wrong number of arguments (0 for 1) I am new to Ruby a...
2005 Sep 27
2
No Custom Validation
Hi, Correct me if I am wrong but there doesn''t seem to be an easy way to add validation outside the pre-built ones (validates_presence_of, validates_lenght_of, etc.). Ideally there should be something like: Class Person < ActiveRecord::Base validates :my_method, :on => create, :message => ''was not valid'' def my_method(param) false unless param ... true end end
2006 Feb 21
11
helper for models?
Is there such a thing? I have some duplicate methods in my models, can I place them somewhere and call them in to my models, thus keeping DRY? -- Posted via http://www.ruby-forum.com/.
2006 Jun 19
1
AJAX - Image output to an IMG tag ?
...I want to update the result directly into to an image ie. <IMG> tag, how to do this.?? ie. if we want to update the result into a ''div'' element we do like this, which works fine.. link_to_remote(:update => ''updatediv'', :url => { :action => :my_method }) But i want to update the output which is an ''Image'' in my case into a HTML IMG tag and display it in the browser. I want to go only for <img> tag.. Thank You Dinesh -- Posted via http://www.ruby-forum.com/.
2007 Jul 16
4
Set the return value to "same as block"
...reading from it. It would be nice to use code like this: object.stubs(:open).with("/path/to/file", "r").yields( stub(:read => "The file contents") ).returns(from_block) Which would make open() take the return value of the block. So this app code would work: def my_method open("/path/to/file", "r") { |file| file.read } end and this wouldn''t work (because the return value of the block is not the contents of the file): def my_method open("/path/to/file", "r") do |file| file.read puts "Stolid in my gui...
2005 Dec 30
6
call a method once per page request
Hi, I''m wondering if there is a simple solution to call a method once per page request. I tried to place my call in a before_filter in ApplicationController but it''d called a second time if I use render_component from a view. Seems to me that a hook should be added in Dispatcher#prepare_application. Context: working on i18n, I''m trying to check lang either from uri,
2004 Mar 02
3
error() and C++ destructors
Hi, I am writing C++ functions that are to be called via .Call() interface. I'd been using error() (from R.h) to return to R if there is an error, but then I realized that this might be not safe as supposedly error() doesn't throw an exception and therefore some destructors do not get called and some memory may leak. Here is a simple example extern "C" void foo() { string
2006 Jun 21
2
access to application.rb methods
Why can''t I access the utility methods defined in applicaion.rb from the model classes? If that does not work, where is the best place to put common utility methods that must be available to all the models. thanks -- Posted via http://www.ruby-forum.com/.
2006 Apr 14
8
Error with Web Service tests after upgrading to Rails 1.1.2
...dencies then I upgraded my application (as myself) with: ? rake rails:update % rake rails:update:configs After these steps, working before Web Services functional tests broke. To try to isolate the problem, I scaffolded a simple Web Services Controller: % ./script/generate web_service Problem my_method Running the test on this Controller, I get: % ruby test/functional/problem_api_test.rb Loaded suite test/functional/problem_api_test Started E Finished in 0.047129 seconds. 1) Error: test_my_method(ProblemControllerApiTest): NoMethodError: You have a nil object when you didn''t expect...
2006 Dec 06
10
Stem Analyzer
Hi all, I am trying to implement a search that will use the Stem Analyzer. I added the Stem Anaylzer from the examples shown in another post http://ruby-forum.com/topic/80178#147014 module Ferret::Analysis class StemmingAnalyzer def token_stream(field, text) StemFilter.new(StandardTokenizer.new(text)) end end end The problem with the Stem analyzer is that when I search for a
2006 Sep 29
2
multiyield
I lied, I don''t actually need different responses each time I call the method. So the last email of mine is probably worthless. Instead, I need yield to yield 3 values when I call it once: (behavior that mimics Find.find) def test_generate(documentation = ''/test_documentation/'', destination = ''/destination/'')
2009 May 06
1
How to extend ActionMailer
...ss instance variable: module ActionMailer class Base class << self def method_name ... What is the magic incantation to accomplish this? I cannot get this to work with action mailer: module MyMethods def self.include(base) base.alias_method_chain :method_name, :my_method def method_name_with_my_method ... stuff method_name_without_my_method end ... end class ActionMailer::Base include MyMethods end require ''my_methods'' -- Posted via http://www.ruby-forum.com/.
2007 Mar 21
4
How to spec error_messages_for
Hi I''m trying to spec a call to error_messages_for to avoid stubbing out whole models. Something like this: context "A rendered calculate_quote view" do setup do @form = mock("form") assigns[:form] = @form end specify "should render the error messages" do <SOMETHING>.should_receive(:error_messages_for).with
2008 Feb 22
7
Testing misc methods in ApplicationController
I''m already successfully testing before_filters in application_controller courtesy of this blog post: http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller However, i can;''t work out how to test the sort of method that is added to application_controller so that all controllers can use it. It must be something simple that i''m doing
2004 Mar 30
12
Big question: Move to SWIG?
A few days ago, someone asked me why I am using wxpp instead of SWIG. The question prompted me to revisit and re-evaluate SWIG, and I now believe it would be best to convert wxRuby to SWIG. SWIG has greatly improved its C++ support since the last time I looked at it, and I think its Ruby support has improved quite a bit as well. Also, now that I have written wxpp, I understand the nature of
2007 Aug 15
8
Extra Options to Heckle
I''ve tried running Heckle with rspec on some of my classes, but keep getting (what I believe to be) an infinite recursion. Is there some way to supply extra options to heckle via. rspec? Scott
2008 Jan 17
6
how to control self.method access
i think self.method just like class method,so if i want to define it as a private method,i should use private_class_method :my_method but i found follow code in < <Agile Web Development with Rails>> private def self.hash_password(password) Digest::SHA1.hexdigest(password) end just a mistake or there have some thing which i cannot get? --~--~---------~--~----~------------~-------~--~----~ You received this message...