#create_booking
:booking_created
:booking_reservation_started
#create_reservation
:reservation_created
:booking_reservation_creation_request_successful
:booking_reservation_added
I hereby claim:
- I am healsjnr on github.
- I am healsjnr (https://keybase.io/healsjnr) on keybase.
- I have a public key ASCPGqgsaMB--PaGSHicvGb4zXjYZzNT9okwl3Jv4CEZBgo
To claim this, I am signing this object:
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
def zipWithPredicate[A,B](predicate: (A, B) => Boolean)(listA: Seq[A], listB: Seq[B]): Seq[(A, B)] = { | |
listA.flatMap(a => listB.find(b => predicate(a, b)).map(b => (a, b))) | |
} |
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
// Can be used as explicit Reads when you want to read any String like Json type into a string. | |
val stringLikeRead: Reads[String] = new Reads[String] { | |
override def reads(json: JsValue): JsResult[String] = { | |
json match { | |
case JsNumber(n) => JsSuccess(n.toString) | |
case JsString(s) => JsSuccess(s) | |
case JsBoolean(b) => JsSuccess(b.toString) | |
case x => JsError(s"Expected a String like Json type (string, boolean or number). Found: $x") | |
} | |
} |
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
trait BaseTrait1 { | |
println("BaseTrait1 Created"); | |
val numVal: Int | |
val listVal: List[Int] | |
println(s" numVal:$numVal\n listVal:$listVal") | |
} | |
trait BaseTrait2 extends BaseTrait1 { | |
println("BaseTrait2 Created"); | |
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
// An example of how a MonadTranformer, particular EitherT, can be used to make complicate business logic far easier to read. | |
class PushTemplateRequestBuilder(messageFilters: ClientFilterRules, campaignTokens: Map[MessageType, String], messagePart: MessagePart) extends TemplateRequestBuilder[CreatePushMessageRequestTemplate] with ServiceResultTransformer { | |
import DisjunctionSupport._ | |
def build(): Future[\/[ServiceFailure, Seq[CreatePushMessageRequestTemplate]]] = { | |
// The following is an example of a complex set of business requirements. In this case we need to ensure that data | |
// retrieved from DBs and WebService meet the criteria for creating an entry in a legacy system. | |
// Using the Transformers we can clearly see at each stage what the requirement is and what the error will be if |
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
# Sum the length of all words starting with t and longer than 5. | |
data = ["test", "alpha", "beta", "delta", "tennis", "time", "temp", "terrible"] | |
t_words = data.select { |x| x.start_with? "t" } | |
t_words_length = t_words.map { |x| x.length } | |
t_words_longer_than_5 = t_words_length.select { |x| x > 5 } | |
t_words_longer_than_5.reduce(0,:+) |
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 Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def filter(filtering_params) | |
# Create an anonymous scope and then reduce it base on key / value | |
filtering_params.inject(self.where(nil)) do |results, (key, value)| | |
results.public_send(key, value) if value.present? | |
end | |
end | |
end |
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 Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def filter(filtering_params) | |
results = self.where(nil) | |
filtering_params.each do |key, value| | |
results = results.public_send(key, value) if value.present? | |
end | |
results |
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 writesTest = contramapWrites(writesWriteable, ((t: Test) => Writeable(t.a, t.b.toString))) | |
NewerOlder