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 Logging | |
def log(level, message) | |
File.open("log.txt", "a") { |f| f.write "#{level}: #{message}" } | |
end | |
end | |
class Service | |
include Logging | |
def do_something |
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 | |
class Vehicule | |
def move | |
'I move' | |
end | |
end | |
# Singleton Class | |
class << Vehicule | |
def available_colors |
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 KlassIncluded | |
def truc | |
puts "KlassIncluded::truc" | |
super | |
end | |
end | |
module KlassExtended | |
def truc | |
puts "KlassExtended::truc" |
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
# extend == include in singleton class | |
module Mincluded | |
def toto | |
puts 'Mincluded#toto' | |
end | |
end | |
module MSingletonIncluded | |
def toto |
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 Mincluded | |
def toto | |
puts 'Mincluded#toto' | |
end | |
module Mprepended | |
def toto | |
puts 'Mprepended#toto' | |
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
module KlassIncluded | |
def truc | |
puts "KlassIncluded::truc" | |
super | |
end | |
end | |
module KlassExtended | |
def truc | |
puts "KlassExtended::truc" |
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
# frozen_string_literal: true | |
# As PostgreSQL documentation states: | |
# https://www.postgresql.org/docs/9.1/queries-order.html | |
# The actual order in that case will depend on the scan and join plan types and the order on disk, | |
# but it must not be relied on. | |
# | |
# Problem is, in 99% of the CI run, in tests, the order will be the same. | |
# And in 1% of the run, regardless how many retries, the order will be different and the test will fail. | |
# Solution here is to "really" randomize requests so that retries will work, |
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
# From https://github.com/doctolib/doctolib/blob/144688fe1aec739ffc6fcf7e6cd30a9d24759f82/test/integration/doctor/desktop/agenda/appointment/modal/booking1_test.rb#L254 | |
# full inherited setup | |
describe 'not described in fact' do | |
setup do | |
@agenda = create :agenda, agenda_options | |
@account = create :account, account_options.merge(kind: Account::Kind::DOCTOR, job: Account::Job::PRACTITIONER) | |
agenda_authorization = create :agenda_authorization, account: account, agenda: agenda | |
@account.update agenda_preferences: @account.agenda_preferences.merge(splitCalendarWeekColumns: false) | |
@date = Time.zone.parse('19th Oct 2013 3:00pm') | |
@date = Time.zone.parse('20th Oct 2016 10:00am') |
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
def run | |
try_results = [] | |
loop do | |
try_results << super | |
if self.class.disable_retry || try_results.count >= MAX_TRIES || try_results.last.failure.nil? | |
break | |
else | |
reset_state | |
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
module A | |
MY_CONST = 'my_value' | |
def self.func1 | |
func2(MY_CONST) | |
MY_CONST == 'my_value' | |
end | |
def self.func2(string) | |
string.next! |
NewerOlder