Module: Flows::Plugin::Interface
- Includes:
- Util::InheritableSingletonVars::DupStrategy.make_module( '@interface_methods' => {} ), Flows::Util::PrependToClass.make_module do def initialize(*) klass = self.class required_methods = klass.instance_variable_get(:@interface_methods).keys missing_methods = required_methods - methods raise MissingMethodsError.new(klass, missing_methods) if missing_methods.any? super end end
- Defined in:
- lib/flows/plugin/interface.rb
Overview
Class extension to define Java/C#-like interfaces in Ruby.
On target class initialization will check defined methods for existence.
Currently interface composition is not supported. You cannot define 2 interface modules and include it into one class.
Defined Under Namespace
Classes: Error, MissingMethodsError
Constant Summary collapse
- SingletonVarsSetup =
Flows::Util::InheritableSingletonVars::DupStrategy.make_module( '@interface_methods' => {} )
- InitializePatch =
Flows::Util::PrependToClass.make_module do def initialize(*) klass = self.class required_methods = klass.instance_variable_get(:@interface_methods).keys missing_methods = required_methods - methods raise MissingMethodsError.new(klass, missing_methods) if missing_methods.any? super end end
Instance Method Summary collapse
Instance Method Details
#defmethod(method_name) ⇒ Object
78 79 80 81 |
# File 'lib/flows/plugin/interface.rb', line 78 def defmethod(method_name) method_list = instance_variable_get(:@interface_methods) method_list[method_name.to_sym] = { required_by: self } end |