# Machinist with Plain Old Ruby Objects

**URL:** <https://www.ruby-forum.com/t/machinist-with-plain-old-ruby-objects/184746>\
**Category:** Ruby\
**Created:** [March 7, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/machinist-with-plain-old-ruby-objects/184746 "2010-03-07T20:56:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_DeNigris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@Sean\_DeNigris](https://www.ruby-forum.com/u/Sean_DeNigris)\
**Post date:** [March 7, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/machinist-with-plain-old-ruby-objects/184746/1 "2010-03-07T20:56:18Z")

</div>

Does anyone have experience with this?

Specifically, I want to use a blueprint for a class that takes an  
argument to new, but calling make (even with an argument) causes an  
error.

Example:  
class MyClass  
def initialize(str)  
…  
end  
end

MyClass.make  
#or  
MyClass.make(‘a string’)  
#or  
MyClass.make(‘new’ =\> ‘a string’)

Output:  
wrong number of arguments (0 for 1)

Thanks.

Sean

---

<div class="post-metadata">

**Author:** ![Sean\_DeNigris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@Sean\_DeNigris](https://www.ruby-forum.com/u/Sean_DeNigris)\
**Post date:** [March 8, 2010, 1:29pm UTC](https://www.ruby-forum.com/t/machinist-with-plain-old-ruby-objects/184746/2 "2010-03-08T13:29:48Z")

</div>

Sean DeNigris wrote:

> Specifically, I want to use a blueprint for a class that takes an  
> argument to new, but calling make (even with an argument) causes an  
> error.
> 
> Example:  
> class MyClass  
> def initialize(str)  
> …  
> end  
> end
> 
> MyClass.make  
> #or  
> MyClass.make(‘a string’)  
> #or  
> MyClass.make(‘new’ =\> ‘a string’)
> 
> Output:  
> wrong number of arguments (0 for 1)

Can you show the source for your ‘make’ class method? The following  
works for me:

class MyClass  
def self.make(\*args)  
new(\*args)  
end  
def initialize(str)  
@str = str  
end  
end  
MyClass.make(“hello”)

---

<div class="post-metadata">

**Author:** ![Sean\_DeNigris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@Sean\_DeNigris](https://www.ruby-forum.com/u/Sean_DeNigris)\
**Post date:** [March 9, 2010, 5:00am UTC](https://www.ruby-forum.com/t/machinist-with-plain-old-ruby-objects/184746/3 "2010-03-09T05:00:56Z")

</div>

> Can you show the source for your ‘make’ class method?  
> Make is a method added to Object by the gem. It did not support  
> objects that take arguments to new. I added the functionality at  
> [http://github.com/lotusone/machinist](http://github.com/lotusone/machinist).

Thanks!

Sean DeNigris
