Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Extraction Blog Post

View contact.rb
1 2 3 4 5 6 7
class Contact < ActiveRecord::Base
belongs_to :user
 
def name
"#{first_name} #{last_name}"
end
end
View contact.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
require 'lib/logic/contact'
 
class FakeContact
include Logic::Contact
attr_accessor :first_name, :last_name
end
 
describe Logic::Contact do
subject do
contact = FakeContact.new
contact.first_name = "Anthony"
contact.last_name = "Eden"
contact
end
 
it "has a name" do
subject.name.should eq("#{subject.first_name} #{subject.last_name}")
end
end
View contact.rb
1 2 3 4 5 6 7 8 9 10
class Domain < ActiveRecord::Base
# ...lots of code...
def auto_renew?
registry_domain.auto_renew?
rescue => e
logger.error e
false
end
# ... more code ...
end
View contact.rb
1 2 3 4 5 6 7 8 9 10 11 12
class Contact < ActiveRecord::Base
include Logic::Contact
belongs_to :user
end
 
module Logic
module Contact
def name
"#{first_name} #{last_name}"
end
end
end
View contact.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Domain < ActiveRecord::Base
include Logic::Domain::Renewable
end
 
module Logic
module Domain
module Renewable
def auto_renew?
registry_domain.auto_renew?
rescue => e
logger.error e
false
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.