Skip to content

Instantly share code, notes, and snippets.

public interface Collection {
Collection <<(Object anObject);
}
public class Array implements Collection {
public Collection << (Object object) {
// add object to me
}
}
public class String implements Collection {
class Address < ActiveRecord::Base
end
class Person < Address
end
class Company < Address
end
class Addressable < ActiveRecord::Base
end
class Person < Addressable
end
class Company < Addressable
end
class Addressable < ActiveRecord::Base
has_one :address
end
addressables (id)
people (id, name, age, height, weight, addressable_id)
companies (id, size, established_date, addressable_id)
addresses (id, street, city, state, addressable_id)
module Addressable
end
module Taggable
end
class Person < ActiveRecord::Base
include Addressable
module Addressable
has_one :address
end
module Addressable
def self.included(klazz) # klazz is that class object that @include@d this module
klazz.class_eval do
has_one :address
end
end
end
addresses (id, street, city, state, person_id, company_id)