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 Policy | |
module Factory | |
class Service | |
class << self | |
def fetch(state) | |
RestClient::Resource.new('someurl').post({state: state}.to_json) | |
end | |
def save(payload) |
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
data = { | |
name: 'RhymeRabbits', | |
artists: [ | |
{ name: "Aesop Hop", | |
id: 1, | |
city: "Seattle", | |
state: "Washington", | |
salary: 100000, | |
albums: [ | |
{ |
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
(ns fizzer.number) | |
(defn divisible-by [num, divisor] | |
(= (mod num divisor) 0)) | |
(defn fizz? [num] (divisible-by num 3)) | |
(defn buzz? [num] (divisible-by num 5)) | |
(defn fizzbuzz? [num] (and (fizz? num) (buzz? num))) | |
(def fizz-map (array-map "Fizzbuzz" fizzbuzz? "Fizz" fizz? "Buzz" buzz?)) |
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
(ns consumer (:require fizzer.number)) | |
(clojure.string/join \newline (map fizzer.number/fizz-value (range 1 100)))) |
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
(ns fizzer.number) | |
(defn divisible-by [num, divisor] | |
(= (mod num divisor) 0)) | |
(defn fizz? [num] (divisible-by num 3)) | |
(defn buzz? [num] (divisible-by num 5)) | |
(defn fizzbuzz? [num] (and (fizz? num) (buzz? num))) | |
(def fizz-map (array-map "Fizzbuzz" fizzbuzz? "Fizz" fizz? "Buzz" buzz?)) |
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
f = FizzBuzzer.new((1..100).to_a) | |
puts f.map(&:fizz_value).join("\n") |
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 FizzBuzzer | |
include Enumerable | |
def initialize(collection) | |
@collection = collection | |
end | |
def each | |
@collection.each do |item| | |
yield FizzNumber.new(item) |
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 FizzNumber | |
FIZZ_MAP = { | |
"Fizzbuzz" => :fizzbuzz?, | |
"Fizz" => :fizz?, | |
"Buzz" => :buzz? | |
} | |
def initialize(number) | |
@number = number |
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 Number | |
def initialize(number) | |
@number = number | |
end | |
def fizz? | |
@number % 3 == 0 | |
end | |
def buzz? |
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 PubSub from 'pubsub-js'; | |
import "reflect-metadata"; | |
import { Container, injectable, inject } from "inversify"; | |
export enum ERRORS { | |
API_ERROR, | |
UNAUTHORIZED | |
} | |
const TYPE = { |