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
| @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 | |
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
| @user = User.new.tap do |user| | |
| user.name = "Mary" | |
| user.email = "[email protected]" | |
| user.age = 23 | |
| user.save! | |
| 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
| @user = User.new | |
| @user.name = "Mary" | |
| @user.email = "[email protected]" | |
| @user.age = 23 | |
| @user.save! |
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 ResultService | |
| def initialize(params) | |
| @params = params | |
| end | |
| def call | |
| define_hash! | |
| end | |
| private |
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 ResultService | |
| def initialize(params) | |
| @params = params | |
| @result_hash = Hash.new | |
| end | |
| def call | |
| define_hash! | |
| 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
| 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" |
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
| 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!'); | |
| } |
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
| 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!'); | |
| } |
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 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" |
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
| Notebook = Struct.new(:cpu, :ram, :ssd) | |
| notebook = Notebook.new("i7", "16GB", "256SSD") |