I have a class Notification::Pseudo in my rails application that has a custom initialize method. I would like this method to capture the output of the block that was passed to new and use that as the value for @message
class Notification::Pseudo
attr_accessor :message
def initialize(&block)
@message = begin
capture(&block) if block_given?
end || ""
end
end
In my view I then have something like
- notification = Notification::Pseudo.new do
This is a test!
This doesn't work though. This gives me the error ArgumentError: wrong number of arguments (0 for 1).
What is wrong w/ my initializer?
capturemethod coming from? The error lies there I think.@messageto be in the case of your example?