This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Variant | |
attr_accessor :price, :sku, :is_master, :product | |
delegate :name, to: :@product, allow_nil: true, prefix: "product" | |
def initialize(data={}) | |
@price = data[:price] | |
@sku = data[:sku] | |
@is_master = data[:is_master] || false | |
@product = data[:product] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'forwardable' | |
# Ici notre class produit hérite de notre delegotr | |
class Product | |
extend Forwardable | |
attr_accessor :name, :variants | |
def_delegators :@obj, :price, :sku | |
def initialize price, sku, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'delegate' | |
# On crée notre classe délégator | |
class MyDelegator < Delegator | |
# retourne l'objet à qui on a déléguer les fonctions | |
def __getobj__ | |
@delegate_sd_obj | |
end | |
# permet de changer l'objet à qui on délégue la fonction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "delegate" | |
class User | |
attr_accessor :firstname, :lastname, :username | |
def initialize(firstname, lastname, username) | |
@firstname = firstname | |
@lastname = lastname | |
@username = username | |
end | |
def iam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "delegate" | |
class Variant | |
attr_accessor :price, :sku, :is_master | |
def initialize(data={}) | |
@price = data[:price] | |
@sku = data[:sku] | |
@is_master = data[:is_master] || false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
attr_accessor :name, :variants | |
def initialize price, sku, | |
master = Variant.new(price: price, sku: sku, is_master: true) | |
@variants = [master] | |
end | |
def add_variant(variant) | |
@variants << variant | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
attr_accessor :name, :variants | |
def initialize price, sku, | |
master = Variant.new(price: price, sku: sku, is_master: true) | |
@variants = [master] | |
end | |
def add_variant(variant) | |
@variants << variant | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\EventSubscriber; | |
use \Doctrine\ORM\Event\LoadClassMetadataEventArgs; | |
use Doctrine\Common\EventSubscriber; | |
class TableSchemaSubscriber implements EventSubscriber | |
{ | |
protected $schemaName = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Challenge DOM Manipulation</title> | |
</head> | |
<body> | |
<div id="root"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const throwMissing = (parent) => { throw new Error(`le nom de ${parent} doit etre renseigné`) } | |
const CodeFamille = (papa = throwMissing("papa"), mere = throwMissing("Maman"), ...children ) => { | |
if(children.length == 0){ | |
console.log(" Pas d'enfants ") | |
return; | |
} | |
console.log("Papa: ", papa, "Maman: ", mere, "enfants :", children ) | |
} |
NewerOlder