Skip to content

Instantly share code, notes, and snippets.

@nafidurmus
Created July 25, 2019 20:14
Show Gist options
  • Save nafidurmus/4c0d99e62c2287c2ccec0903fef57ccb to your computer and use it in GitHub Desktop.
Save nafidurmus/4c0d99e62c2287c2ccec0903fef57ccb to your computer and use it in GitHub Desktop.
# Prototype Pattern kullanmadan
class ProductDefinition
def create_product
@product = Product.new(
product_definition_name: self.name,
properties: self.properties,
active: self.active?,
category: self.category
)
end
end
#------------------------------------
class Product
end
# Prototype Pattern kullanarak
class Product
def _clone(product_definition)
Product.new(
self.product_definition_name(product_definition),
self.properties,
self.active?,
self.category
)
end
end
#kullanımı
product_prototype = Product.new
product_instance_a = product_prototype._clone("Telescope")
product_instance_b = product_prototype._clone("Light Saber")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment