module Flows::Plugin::Interface

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.

@example Simple interface

class MyAction
  extend Flows::Plugin::Interface

  defmethod :perform
end

class InvalidAction < MyAction; end
InvalidAction.new
# will raise an error

class ValidAction < MyAction
  def perfrom
    puts 'Hello!'
  end
end
ValidAction.new.perform
# => Hello!

@example Interface as module

module MyBehavior
  extend Flows::Plugin::Interface

  defmethod :my_method
end

class MyImplementation
  include MyBehaviour

  def my_method; end
end

Constants

InitializePatch
SingletonVarsSetup

Public Instance Methods

defmethod(method_name) click to toggle source
# 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