Skip to content

Instantly share code, notes, and snippets.

View mleszcz's full-sized avatar

Mateusz Leszczyński mleszcz

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