Logo

Programming-Idioms

History of Idiom 73 > diff from v323 to v324

Edit summary for version 324 by programming-idioms.org:
[Ruby] p_fact -> fact

Version 323

2016-06-12, 16:56:11

Version 324

2016-06-12, 16:56:33

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Code
def p_fact(klass, str)
  klass.new(str) if klass.is_a?(Parent)
end
Code
def fact(klass, str)
  klass.new(str) if klass.is_a?(Parent)
end