Class: Webmidi::Middleware::ChannelMap
- Defined in:
- lib/webmidi/middleware/channel_map.rb
Instance Method Summary collapse
- #call(message) ⇒ Object
-
#initialize(app, map: nil, from: nil, to: nil, **options) ⇒ ChannelMap
constructor
A new instance of ChannelMap.
Constructor Details
#initialize(app, map: nil, from: nil, to: nil, **options) ⇒ ChannelMap
Returns a new instance of ChannelMap.
6 7 8 9 |
# File 'lib/webmidi/middleware/channel_map.rb', line 6 def initialize(app, map: nil, from: nil, to: nil, **) super(app, **) @map = normalize_map(map, from, to) end |
Instance Method Details
#call(message) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/webmidi/middleware/channel_map.rb', line 11 def call() return @app.call() unless .channel target = @map.fetch(.channel, .channel) @app.call(.with(channel: target)) end |