Skip to content

Instantly share code, notes, and snippets.

@tylr
Created August 29, 2013 19:10
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 tylr/6382163 to your computer and use it in GitHub Desktop.
Save tylr/6382163 to your computer and use it in GitHub Desktop.
class Base
attr_reader :name, :config
attr_accessor :operations
def initialize(name, opts={})
@name = name
@config = opts
self.operations = {
:"#{name}" => proc do |*args, &block|
end,
:"#{name}=" => proc do |*args, &block|
end
}
end
def define!
operations.each do |method_name, proc|
define_method(method_name) do |*args, &block|
proc.call(*args, &block)
end
end
register!
end
private
def register!
TYPES[name] = self.class
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment