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
package com.example.copy; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedOutputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; |
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 B | |
module_function | |
def b | |
puts 'b' | |
end | |
end | |
B.b # => '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
module Storage | |
module Models | |
class Brand < ActiveRecord::Base; 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
require 'forwardable' | |
class LazyEmployee | |
extend Forwardable | |
def initialize(sandwich_maker) | |
@sandwich_maker = sandwich_maker | |
end | |
def_delegators :@sandwich_maker, :make_me_a_sandwich |
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
defmodule PipelinexTest do | |
use ExUnit.Case, async: true | |
use Pipelinex | |
require Pipelinex | |
@text "Some random STRING." | |
describe "~>" do | |
test "should behave the same as the regular pipe operator" do |
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
defmodule PipelinexTest do | |
use ExUnit.Case, async: true | |
alias Pipelinex.{Video, Rating} | |
describe "serialize" do | |
@rating1 %Rating{author: "James Bond", comment: "Quite nice."} | |
@rating2 %Rating{author: "Sherlock Holmes", comment: "Pretty good."} | |
@ratings [@rating1, @rating2] | |
@video %Video{title: "Iron Man 3", ratings: @ratings} |
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
defmodule Pipelinex.Rating do | |
@enforce_keys ~w(author comment)a | |
defstruct @enforce_keys | |
def new(params), do: struct!(__MODULE__, params) | |
def encode(%__MODULE__{author: author, comment: comment}) do | |
%{ | |
"author" => author, | |
"comment" => comment |
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
defmodule Download do | |
use Pipe | |
def start(api_key) do | |
api_key | |
~> download() | |
~> parse() | |
end | |
defp download(123), do: {:ok, "valid result"} |
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
[1] (pry) main: 0> add = -> (a, b) { a + b } | |
=> #<Proc:0x007ffde11d72c0@(pry):1 (lambda)> | |
# Call proc with two arguments | |
[2] (pry) main: 0> add.(1, 2) | |
=> 3 | |
# Call proc with one argument | |
[3] (pry) main: 0> add.(1) | |
ArgumentError: wrong number of arguments (1 for 2) |
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 BrandInMemoryAdapter | |
attr_accessor :db | |
def initialize | |
@db = [] | |
end | |
def all | |
db | |
end |
NewerOlder