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 Square < Rectangle | |
def set_width(width) | |
@width = width | |
@height = height | |
some_ui_width_related_callbacks | |
some_ui_height_related_callbacks | |
end | |
def set_height(height) | |
set_width(height) |
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 AdminUser | |
def initialize(settings_array) | |
settings_from_array(settings_array) | |
end | |
# ew. dodatkowo | |
def settings=(settings_array) | |
settings_from_array(settings_array) | |
end | |
def settings_from_array(settings_array) |
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 Rectangle | |
attr_accessor: :width, :height | |
def set_width(width) | |
@width = width | |
some_ui_width_related_callbacks | |
end | |
def set_height(height) | |
@height = height |
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 active? | |
if self.class == User | |
@settings[:status] == :active | |
elsif self.class == AdminUser | |
@settings[1] == :active | |
end | |
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 User | |
attr_accessor :settings | |
def active? | |
@settings[:status] == :active | |
end | |
end | |
class AdminUser < User | |
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 Api | |
def self.recent_orders | |
Order.recent | |
end | |
end | |
client1 = Api.recent_orders | |
client2 = Api.recent_orders | |
client3 = Api.recent_orders |
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 Api | |
def self.recent_orders | |
Order.recent | |
end | |
end | |
class IngeniousClientsApi | |
def self.recent_orders | |
Api.recent_orders.take(10) | |
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 Moderator | |
extend Forwardable | |
def_delegators :@blog_actions :edit_post | |
def initialize(blog_actions) | |
@blog_actions = blog_actions | |
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 BlogActions | |
def create_post; end | |
def edit_post; end | |
def delete_post; end | |
end | |
class Moderator < BlogActions | |
end | |
moderator = Moderator.new |
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 OrderRepor | |
attr_accessor :attributes | |
def initialize(various_attributes) | |
@attributes = various_attributes | |
end | |
def print_out | |
puts "Summary title" | |
yield @attributes |