-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return unknown operation_details in parser #26
Changes from 3 commits
8be9ee1
d9cb64a
a26bdca
5eaa480
b91ecf4
e94eafd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ def self.register(code, klass) | |
end | ||
|
||
def self.for(line) | ||
@details[line.detail_code] | ||
return unless line.respond_to?(:detail_code) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can avoid this no by making returning an Unknown class for each unknown code ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do that below, this was to prevent cases where the file might be corrupted and we didn't have a detail_code at all (since we need the detail code for both know known and unknown classes). Maybe I should raise instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally an unknown should respond to detail code |
||
|
||
@details[line.detail_code] || Unknown | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module CFONB | ||
module OperationDetails | ||
class Unknown < Base | ||
ATTRIBUTES = %i[unknown].freeze | ||
|
||
def self.apply(details, line) | ||
details.unknown ||= {} | ||
code = line.detail_code | ||
|
||
details.unknown[code] = | ||
if details.unknown[code] && line.detail.is_a?(String) | ||
details.unknown[code] + "\n#{line.detail}" | ||
else | ||
line.detail | ||
end | ||
end | ||
|
||
CFONB::OperationDetails.register('Unknown', self) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add an example of how it can look like and how to access a specific code