Skip to content

Instantly share code, notes, and snippets.

View anchietajunior's full-sized avatar
💭
Working Hard

José Anchieta anchietajunior

💭
Working Hard
View GitHub Profile
@user = User.new.tap do |user|
user.name = "Mary"
user.age = 23
if user.email.present?
user.email = "[email protected]"
else
user.email = "[email protected]"
end
@user = User.new.tap do |user|
user.name = "Mary"
user.email = "[email protected]"
user.age = 23
user.save!
end
@user = User.new
@user.name = "Mary"
@user.email = "[email protected]"
@user.age = 23
@user.save!
class ResultService
def initialize(params)
@params = params
end
def call
define_hash!
end
private
class ResultService
def initialize(params)
@params = params
@result_hash = Hash.new
end
def call
define_hash!
end
@anchietajunior
anchietajunior / hash_method.rb
Last active August 18, 2018 02:07
working with tap and hashes
def define_hash(customer, payment_type)
my_hash = {}
if customer.nil?
my_hash.store(:customer, "Customer is not defined")
else
my_hash.store(:customer, customer)
end
if payment_type == "credit_card"
async function getStarWarsPeople() {
const request = await fetch('https://swapi.co/api/people');
const data = await request.json();
data.results.map(person => {
console.log(person.name);
})
console.log('Luke i`m your father!');
}
function getStarWarsPeople() {
fetch('https://swapi.co/api/people')
.then(data => data.json())
.then(data => data.results.map(person => {
console.log(person.name);
}))
console.log('Luke i`m your father!');
}
class StatusService
Status = Struct.new(success?, errors)
def initialize(request_params)
@request_params = request_params
end
def call
if @request_params[:status].present? && @request_params[:status] == "success"
Notebook = Struct.new(:cpu, :ram, :ssd)
notebook = Notebook.new("i7", "16GB", "256SSD")