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 CreateUserService | |
def initialize(user_attributes) | |
@user_attributes = user_attributes | |
end | |
def call | |
puts "Creating user with following attributes.." | |
p @user_attributes | |
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
class Rapper < ApplicationRecord | |
belongs_to :agent, class_name: "User" | |
has_many :bookings | |
end | |
class User < ApplicationRecord | |
has_many :rappers, foreign_key: :agent_id | |
has_many :bookings | |
# source: -> pour spécifier à AR qu'il doit aller chercher la relation bookings du rapper comme source pour les reservations |
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 PrivateAttrMethodsDecorators | |
module Explicit | |
module ClassMethods | |
def private_attr_reader(*attributes) | |
attributes.each do |attr| | |
attr_reader attr | |
private attr | |
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
CyLemeunier |