Created
August 29, 2013 19:10
-
-
Save tylr/6382163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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