Created
May 22, 2013 11:49
-
-
Save alpaca-tc/5626985 to your computer and use it in GitHub Desktop.
This file contains 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
module Interface | |
def self.method_check(method_name, *expect_params) | |
@interface_defines = {} unless @interface_defines | |
@interface_defines[method_name] = *expect_params | |
end | |
def self.append_features(k) | |
@interface_defines.each do |method_name, expect_params| | |
if k.respond_to?(method_name) | |
method = k.method(method_name) | |
params = method.parameters | |
# TODO params と expect_paramsが一致する処理 | |
else | |
raise "No method error occured" | |
end | |
end | |
end | |
method_check :helloworld | |
method_check :echo, :text | |
end | |
class Hoge | |
def self.helloworld | |
p "helloworld" | |
end | |
def self.echo(text) | |
p "text" | |
end | |
include Interface | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment