Skip to content

Instantly share code, notes, and snippets.

@nickyp
Created October 7, 2010 16:23
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 nickyp/615388 to your computer and use it in GitHub Desktop.
Save nickyp/615388 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'active_support'
class Base
class_inheritable_accessor :name
self.name = "Base"
end
class Foo < Base
self.name = "Foo"
end
f = Foo.new
puts f.name
b = Base.new
puts b.name
# Foo
# Foo
module Scenarios
class ScenarioError < StandardError
class_inheritable_accessor :messages
self.messages = {
:foo => lambda { "bar" }
}
def initialize(message_key, *args)
super(messages[message_key].call(*args))
end
end
class FooError < ScenarioError
self.messages.merge!({:bar => lambda { "foo"}})
end
end
#raise Scenarios::FooError.new(:bar)
p Scenarios::FooError.messages.inspect
raise Scenarios::FooError.new(:foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment