This file contains hidden or 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
<main> | |
<% @posts.each do |post| %> | |
<!-- Under the hood, we find the right file in webpack and attach the expected object to window.Post --> | |
<Post | |
title={post.title} | |
description={post.description} | |
/> | |
<% end %> | |
</main> |
This file contains hidden or 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
<<~MSG | |
Squiggle | |
MSG | |
<<-MSG | |
No-squigs | |
MSG | |
CHONSTANT = 'CONSTANT' |
This file contains hidden or 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 PayrollCalculator | |
def initialize(payroll, options = {}) | |
@payroll = payroll | |
@skip_benefits = options[:skip_benefits] | |
@skip_taxes = options[:skip_taxes] | |
@skip_donations = options[:skip_donations] | |
end | |
def calculate | |
if !@skip_benefits |
This file contains hidden or 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 taxes | |
PayrollCalculator::Taxes.calculate( | |
@payroll.only_pay_and_location_data | |
) | |
end |
This file contains hidden or 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
# This methods adds 2 numbers together | |
# @param x [Number] The first number that you would | |
# like to add | |
# @param y [Number] The number you would | |
# like to add to the first number | |
# @return [Number] The result of adding `x` and `y` together | |
def add(x, y) | |
x + y | |
end |
This file contains hidden or 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
'use strict'; | |
const http = require('https'); | |
// Forward the button press onto our Heroku app | |
// as a POST request with a JSON body. | |
exports.handler = (event, context, callback) => { | |
const params = { | |
serialNumber: event.serialNumber, | |
event: event |
This file contains hidden or 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 'rails_helper' | |
RSpec.describe FrequentFlierCreator do | |
describe '.create' do | |
subject do | |
described_class.create( | |
customer, | |
starting_balance, | |
status_level | |
) |
This file contains hidden or 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
RSpec.describe User do | |
describe '#full_name' do | |
subject do | |
described_class.new(first_name, middle_name, last_name) | |
end | |
let(:first_name) { 'Roy' } | |
let(:last_name) { 'Biv' } | |
context 'middle name is given' do | |
let(:middle_name) { 'Gee' } |
This file contains hidden or 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 PayrollRunner | |
def run! | |
TaxEngineWrapper.new(tax_engine).apply(commands) | |
computed_taxes = tax_engine.calculate_taxes | |
payroll.assign_taxes(computed_taxes) | |
end | |
# This is now a pure function from the view of its callers. | |
# Sweet! | |
def commands |
This file contains hidden or 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 TaxCalculationSaver | |
def self.save_taxes!(payroll) | |
total_tax_amount = payroll.employees.map do |employee| | |
TaxCalculator.calculate(payroll, employee) | |
end.sum | |
PayrollSaver.save!(payroll, total_tax_amount: total_tax_amount) | |
end | |
end |
NewerOlder