Skip to content

Instantly share code, notes, and snippets.

@lululau
Created January 7, 2020 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lululau/177254d3c3246cf6a20fe935355f55fc to your computer and use it in GitHub Desktop.
Save lululau/177254d3c3246cf6a20fe935355f55fc to your computer and use it in GitHub Desktop.
module Concerns
module Institution
module IOProcessorAble
extend ActiveSupport::Concern
def dq_io_processor(params={})
io_processor_of('dq', params)
end
def hq_io_processor(params={})
io_processor_of('hq', params)
end
private
def io_processor_of(type, params)
institution_code = code.camelize
params[:exchange] = self if self.class == Exchange
params[:consignee] = self if self.class == Consignee
format('IOProcessor::%s::%s', type.camelize, institution_code).safe_constantize.try(:new, params)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment