Skip to content

Instantly share code, notes, and snippets.

@gabeodess
Created May 13, 2015 02:38
Show Gist options
  • Save gabeodess/05f0927c606d01fe768b to your computer and use it in GitHub Desktop.
Save gabeodess/05f0927c606d01fe768b to your computer and use it in GitHub Desktop.
Class Inheritance
class Shippo::Address < Shippo::TestBase
@@store = {:test => 'Address'}
cattr_reader :store
end
class Shippo::TestBase
def self.create(options)
options[:id] = rand
@@store[options[:id]] = options
end
end
Shippo::Address.create({})
NameError: uninitialized class variable @@store in Shippo::TestBase
from /Users/gabeodess/Sites/share_coffee/test/stubs/shippo/test_base.rb:5:in `create'
class Shippo::Transaction < Shippo::TestBase
@@store = {:tst => 'transaction'}
cattr_reader :store
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment