Skip to content

Instantly share code, notes, and snippets.

@theCrab
Created June 21, 2013 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theCrab/91787faf5179a63c4199 to your computer and use it in GitHub Desktop.
Save theCrab/91787faf5179a63c4199 to your computer and use it in GitHub Desktop.
Pure RUBY PORO to illustrate business logic separation from Frameworks.
class Company
include Address, Owner, Email, PhoneNumber
attr_accessor :name, :address, :phone_number, :email, :owner
def initialize(name)
@name = name
@address ||= address #new company address
...
end
end
class Vehicle
attr_accessor :reg_plate, :make, :model, :date_of_reg, :seat_capacity, :lincese
end
class Address
attr_accessor :line_one, :line_two, :city, :state, :post_code, :company, :owner
end
class Owner
include Address, Company, Email, PhoneNumber
attr_accessor :first_name, :last_name, :address, :email, :phone_number
def initialize(first_name, last_name)
@first_name, @last_name = first_name, last_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment