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
object factorial { | |
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet | |
def factorial(n : Int) : Int = { | |
if (n == 0) 1 else n * factorial(n-1) | |
} //> factorial: (n: Int)Int | |
def factorial2(n : Int) : Int = { | |
def innerFact(n : Int, count : Int, acum : Int) : Int = { |
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
FactoryPal.register[Person]() { person => | |
person.name.mapsTo("gonto") 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
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
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
//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 |
OlderNewer