Module: AbstractInterface::SingletonMethods
- Defined in:
- lib/ruby_us/abstract_interface.rb
Instance Method Summary collapse
- #implements(interface, &block) ⇒ Object
- #needs_implement_method(method_name) ⇒ Object
- #needs_implement_singleton_method(method_name) ⇒ Object
Instance Method Details
#implements(interface, &block) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/ruby_us/abstract_interface.rb', line 46 def implements interface, &block interface_instance = Interface.new self, interface interface.module_eval do block.call interface_instance end if block_given? end |
#needs_implement_method(method_name) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/ruby_us/abstract_interface.rb', line 53 def needs_implement_method method_name interface = self.name define_method method_name do |*args| interface, method_name end end |
#needs_implement_singleton_method(method_name) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ruby_us/abstract_interface.rb', line 60 def needs_implement_singleton_method method_name self.module_eval do interface_name = self.name constant = self::SingletonMethods constant.module_eval do define_method method_name do |*args| interface_name, method_name end end end end |