Class: Taksi::Interface
- Inherits:
-
Module
- Object
- Module
- Taksi::Interface
- Defined in:
- lib/taksi/interface.rb
Overview
A custom module that turns a class into a interface on taksi protocol
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Instance Attribute Summary collapse
-
#alternatives ⇒ Object
readonly
Returns the value of attribute alternatives.
-
#interface_name ⇒ Object
readonly
Returns the value of attribute interface_name.
-
#version_pattern ⇒ Object
readonly
Returns the value of attribute version_pattern.
Class Method Summary collapse
-
.find(name, version, alternative: nil) ⇒ Object
Finds for a interface by its name and the current version @raises`::Taksi::Registry::InterfaceNotFoundError`.
Instance Method Summary collapse
- #included(klass) ⇒ Object
-
#initialize(name, version_pattern = nil, alternatives: nil) ⇒ Interface
constructor
A new instance of Interface.
Constructor Details
#initialize(name, version_pattern = nil, alternatives: nil) ⇒ Interface
Returns a new instance of Interface.
19 20 21 22 23 24 |
# File 'lib/taksi/interface.rb', line 19 def initialize(name, version_pattern = nil, alternatives: nil) @interface_name = name @version_pattern = ::Gem::Requirement.new(version_pattern) @alternatives = alternatives super() end |
Instance Attribute Details
#alternatives ⇒ Object (readonly)
Returns the value of attribute alternatives.
7 8 9 |
# File 'lib/taksi/interface.rb', line 7 def alternatives @alternatives end |
#interface_name ⇒ Object (readonly)
Returns the value of attribute interface_name.
7 8 9 |
# File 'lib/taksi/interface.rb', line 7 def interface_name @interface_name end |
#version_pattern ⇒ Object (readonly)
Returns the value of attribute version_pattern.
7 8 9 |
# File 'lib/taksi/interface.rb', line 7 def version_pattern @version_pattern end |
Class Method Details
.find(name, version, alternative: nil) ⇒ Object
Finds for a interface by its name and the current version @raises`::Taksi::Registry::InterfaceNotFoundError`
15 16 17 |
# File 'lib/taksi/interface.rb', line 15 def self.find(name, version, alternative: nil) ::Taksi::Registry.find(name, version, alternative) end |
Instance Method Details
#included(klass) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/taksi/interface.rb', line 26 def included(klass) klass.extend(ClassMethods) klass.include(InstanceMethods) klass.initiate(self) ::Taksi::Registry.add(klass, interface_name) end |