Skip to content

Instantly share code, notes, and snippets.

@alpaca-tc
Created May 22, 2013 11:49
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 alpaca-tc/5626985 to your computer and use it in GitHub Desktop.
Save alpaca-tc/5626985 to your computer and use it in GitHub Desktop.
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