This file contains 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 person = FactoryPal.create[Person] |
This file contains 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 person = FactoryPal.create[Person]() { (person : ObjectBuilder[Person]) => | |
person.age.mapsTo(45) alone | |
} |
This file contains 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
//Default template creation | |
FactoryPal.register[Person]() { person => | |
person.name.mapsTo("gonto") and | |
person.age.isRandom | |
} | |
//Creating template for a certain name. This way you can create multiple templates for a certain class | |
FactoryPal.register[Person](Some('coolPerson)) { person => | |
person.name.mapsTo("cool") and | |
person.age.isRandom |
This file contains 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
//Create a person from default template | |
val person = FactoryPal.create[Person] | |
//Creating a Person for cool template | |
val person = FactoryPal.create[Person](Some('coolPerson))() |
This file contains 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 sbt._ | |
import sbt.Keys._ | |
object ApplicationBuild extends Build { | |
lazy val root = Project( | |
id = "factory_pal_sample", | |
base = file("."), | |
settings = Project.defaultSettings ++ Seq( | |
name := "factory_pal_sample", |
This file contains 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
nfo] Compiling 2 Scala sources to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/classes... | |
Children are List()[info] | |
Compiling 1 Scala source to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/test-classes... | |
Children are List(class PalObject1, class PalObject2)Children are List(class PalObject1, class PalObject2)0Set()[info] |
This file contains 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 UsersController < ApplicationController | |
respond_to :json | |
before_filter :authenticate_user!, :only => :destroy | |
def create | |
@user = User.new(params[:user]) | |
if @user.save | |
respond_with @user, status: :created | |
else |
This file contains 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
// bad | |
if (currentUser) { | |
function test() { | |
console.log('Nope.'); | |
} | |
} | |
// good | |
if (currentUser) { | |
var test = function test() { |
This file contains 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 module = angular.module('basicsite', | |
['ngResource']). | |
config(['$routeProvider', function ($routeProvider) { | |
$routeProvider. | |
when('/', | |
{templateUrl: '/js//views/main.html', controller: 'MainCtrl'}). | |
when('/sports', | |
{templateUrl: '/js/views/sports.html', controller: 'SportsCtrl'}). | |
when('/players', | |
{templateUrl: '/js/views/players.html', controller: 'PlayersCtrl'}). |
This file contains 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.directive('footer', function () { | |
return { | |
restrict: 'A', //This menas that it will be used as an attribute and NOT as an element. I don't like creating custom HTML elements | |
replace: true, | |
templateUrl: "/js/directives/footer.html", | |
controller: ['$scope', '$filter', function ($scope, $filter) { | |
// Your behaviour goes here :) | |
}] | |
} | |
}); |