Module: Interchange::Methods
- Defined in:
- lib/interchange.rb
Instance Method Summary collapse
- #check ⇒ Object
- #down? ⇒ Boolean
- #implementation ⇒ Object
- #implementations ⇒ Object
- #register(name, implementation) ⇒ Object
- #use(name) ⇒ Object
- #with(name) ⇒ Object
Instance Method Details
#check ⇒ Object
66 67 68 69 |
# File 'lib/interchange.rb', line 66 def check fail NotAvailableError, implementation unless up? true end |
#down? ⇒ Boolean
62 63 64 |
# File 'lib/interchange.rb', line 62 def down? !up? end |
#implementation ⇒ Object
75 76 77 |
# File 'lib/interchange.rb', line 75 def implementation @implementation end |
#implementations ⇒ Object
71 72 73 |
# File 'lib/interchange.rb', line 71 def implementations @implementations ||= { } end |
#register(name, implementation) ⇒ Object
43 44 45 |
# File 'lib/interchange.rb', line 43 def register(name, implementation) implementations[name] = implementation end |
#use(name) ⇒ Object
47 48 49 50 51 |
# File 'lib/interchange.rb', line 47 def use(name) @implementation = implementations.fetch name do raise UnregisteredError, name end end |
#with(name) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/interchange.rb', line 53 def with(name) original = implementation use name result = yield self @implementation = original result end |