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 Notification | |
def initialze(kind, body) | |
@kind, @body = kind, body | |
end | |
def send_sms_notification | |
# sends a sms notification | |
end | |
def send_email_notification |
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 Employee | |
def initialize(name, base_salary) | |
@name = name | |
@base_salary = base_salary | |
end | |
def calculate_net_salary | |
# business logic about how to calculate the net salary | |
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 Employee | |
def initialize(name, base_salary) | |
@name = name | |
@base_salary = base_salary | |
end | |
def calculate_net_salary | |
# business logic about how to calculate the net salary | |
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 User | |
def initialize(name, user_information={}) | |
@name = name | |
@phone_number = user_information[:phone_number] || NullPhoneNumber.new | |
end | |
def name | |
@name | |
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 User | |
def initialize name, user_information={} | |
@name = name | |
@phone_number = user_information[:phone_number] | |
end | |
def name | |
return @name | |
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 Company | |
def open_headquarter headquarter | |
@headquarters << headquarter | |
end | |
def close_headquarter(headquarter_name) | |
@headquarters.delete_if{ |headquater| headquarter.name == headquarter_name } | |
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 Example | |
def initialize(headquarters, positions) | |
@positions = positions | |
@headquarters = headquarters | |
end | |
def open_headquarter(headquarter) | |
@headquarters[headquarter] = [] | |
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 Invoice | |
def initialize *lines | |
@lines = lines | |
end | |
def total | |
@lines.inject(0){ |subtotal, line| subtotal += line_subtotal(line) } | |
end | |
def line_subtotal line |
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 Invoice | |
def initialize *lines | |
@lines = lines | |
end | |
def total | |
@lines.inject(0){ |subtotal, line| subtotal += line.total } | |
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
# Update the attributes of a post/article/kata, and generate a notice if the changes could | |
# be saved or retry to edit otherwise. | |
# The attributes to be saved are different between Post and Kata. | |
# For Post, tags and source url need to be saved. | |
# For Kata, categories, challenge level and source url need to be saved. | |
def update | |
@post = post_type.find_by_slug(params[:id]) | |
authorize! :update, @post | |
@form = params[@type.downcase.to_sym] |