-
-
Save krazylegz/bf6d91c7a2e9298fe356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| New: | |
| class BaseNotifier | |
| def initialize(attributes={}) | |
| @client_ip, @ec2_instance_id, @environment, @hl7_message, | |
| @hl7_response, @queue_response, @stats, @title = %i( | |
| client_ip ec2_instance_id environment hl7_message | |
| hl7_response queue_response stats title | |
| ).map do |key| | |
| attributes.fetch(key, '') | |
| end | |
| @pass = attributes.fetch(:pass, false) | |
| end | |
| Original: | |
| class BaseNotifier | |
| def initialize(data) | |
| @client_ip = data.fetch(:client_ip, '') | |
| @ec2_instance_id = data.fetch(:ec2_instance_id, '') | |
| @environment = data.fetch(:environment, '') | |
| @hl7_message = data.fetch(:hl7_message, '') | |
| @hl7_response = data.fetch(:hl7_response, '') | |
| @pass = data.fetch(:pass, false) | |
| @queue_response = data.fetch(:queue_response, '') | |
| @stats = data.fetch(:stats, '') | |
| @title = data.fetch(:title, '') | |
| end | |
| end | |
| Another option: | |
| module HL7Engine | |
| module Interfaces | |
| module Labs2Go | |
| # Base notification | |
| class BaseNotifier | |
| INSTANCE_VARIABLE_NAMES = %i( | |
| client_ip ec2_instance_id environment hl7_message hl7_response | |
| queue_response stats title | |
| ) | |
| def initialize(attributes = {}) | |
| INSTANCE_VARIABLE_NAMES.each do |name| | |
| instance_variable_set("@#{name}".to_sym, attributes.fetch(name, '')) | |
| end | |
| @pass = attributes.fetch(:pass, false) | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment