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 aFunction() { | |
// primitives are stored directly on the stack | |
const foo = 1; | |
// obects which do not escape the scope of a function will | |
// be allocated on the stack and will be freed automatically | |
// on return | |
const bar = { | |
stack: 123 | |
}; |
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
// Models have references to the global store | |
// which has a reference to the container | |
const Bar = DS.Model.extend({}); | |
const Foo = Ember.Object.extend({ | |
someData: [] | |
}); | |
const aFoo = Foo.create({}); | |
// by pushing this model on to the prototype | |
// we've sprung a leak |
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 Foo = Ember.Object.extend({ | |
// this is being placed on the Foo prototype | |
// and will be shared between all instances of foo | |
someData: [] | |
}); | |
const aFoo = Foo.create({}); | |
const anotherFoo = Foo.create({}); |
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 Ember from 'ember'; | |
import { before, beforeEach, afterEach, after } from 'mocha'; | |
import { getContext } from 'ember-test-helpers'; | |
export default function(Constructor) { | |
return function setupTest(moduleName, options = {}) { | |
var module; | |
var contextBefore; | |
if (Ember.typeOf(moduleName) === 'object') { |
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
Option<String> maybeString = someFunction(); | |
String foo = maybeString.getOrElse("I'm some other string") | |
String foo2 = maybeString.getOrElse(() -> "I'm a string returned from a java lambda which has a -> instead of a =>.") |
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
val maybeFoo:Option[String] = some_function() | |
val foo:String = maybeFoo.getOrElse("There was no foo!") | |
val foo2:String = maybeFoo.getOrElse(() => "There was no foo, so we called this function!") |
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
# example usage, currently has one menu item, and many menu_option_items | |
# if there is a snapshot of the menu on the order, we use the data structures there | |
# instead of the ar associations | |
class OrderItem | |
include SnapshotSupport | |
belongs_to :menu_snapshot, through: :order | |
has_one :menu_item | |
has_many :menu_option_items |
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
module Snapshot | |
class Base | |
attr_accessor :snapshot_type | |
attr_accessor :active_record_type | |
# serializes attributes and relationships as a hash for storage in json B columns | |
def serialize | |
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
export class AppConfiguration { | |
// attributes | |
id: number; | |
key: string; | |
preferences: string; | |
// relationships | |
versions:Version[]; | |
} |
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
# example usage | |
class SomeService | |
# lets say Foo and Bar are AR models so they will be injected as classes | |
# I've been cooking up a further idea here to perhaps decorate the service | |
# call with another kind of dependency that would allow you to map the params | |
# to AR models or something... still a WIP though | |
dependency :foo_dao, Foo | |
dependency :bar_dao, Bar |