Showing content from https://gist.github.com/mbrowne below:
mbrowne’s gists · GitHub
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 import autoExternal from 'rollup-plugin-auto-external' import json from '@rollup/plugin-json' import ts from 'rollup-plugin-ts' export default { input: ['src/index.ts'], plugins: [ // allow .json files to be imported json(), 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 addEntry = Symbol('addEntry'), getBalance = Symbol('getBalance'); export default class Account { constructor(ledgers) { const roles = { ledgers: { [addEntry](message, amount) { ledgers.push(new LedgerEntry(message, amount)); }, 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 /* This is just a demo to show the concept. For a full implementation, see https://github.com/mbrowne/dci-php */ trait RolePlayer { private $roles = []; private $roleMethods = []; 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 function CustomError(message) { if (!(this instanceof CustomError)) { throw new TypeError("Constructor 'CustomError' cannot be invoked without 'new'"); } var err; if (Object.setPrototypeOf) { err = new Error(message); Object.setPrototypeOf(err, CustomError.prototype); } 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 //TransferMoney context class TransferMoney: Context { private let SourceAccount: SourceAccountRole private let DestinationAccount: DestinationAccountRole init(source:AccountData, destination:AccountData) { SourceAccount = source as! SourceAccountRole DestinationAccount = destination as! DestinationAccountRole 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 /** * Transfer Money use case */ function TransferMoney(sourceAcct: Account, destinationAcct: Account, amount: number) { //bind the objects to their roles SourceAccount <- sourceAcct; DestinationAccount <- destinationAcct; Amount <- amount; 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 var Animal = { init: function(name) { this.name = name || null; } } var Cat = Object.create(Animal); Cat.meow = function() { console.log('meow'); } 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 #!/bin/bash #SYNC MONGODB DATABASE FROM REMOTE SERVER #NOTE: This overwrites the local copy of the database remoteHost='yourhost.com' remoteDbUser='root' remoteDbPasswd='password123' remoteDb='test' localDb='test' 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 UseCases { class TransferMoney extends \DCI\Context { //These would ideally be private but they need to be public so that the roles can access them, //since PHP doesn't support inner classes public $sourceAccount; public $destinationAccount; 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 DCI; /** * DCI Role base class */ abstract class Role { /** * The data object playing this role (the RolePlayer).
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4