Created
April 27, 2016 13:10
-
-
Save gaetanm/ec49a7785d8471241796c96b3491e0c4 to your computer and use it in GitHub Desktop.
This file contains 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
class JobOffer::Localized | |
def initialize(job_offer, language) | |
@job_offer = job_offer | |
if language == JobOfferContent.languages[:fr] | |
@localized_content_to_use = job_offer | |
else | |
@localized_content_to_use = job_offer.job_offer_contents.find_by_language language | |
end | |
end | |
def method_missing(method_name, *args) | |
job_offer_methods = %i[title description display_location salary custom_summary question_set] | |
if job_offer_methods.include? method_name | |
@localized_content_to_use&.public_send(method_name, *args) | |
else | |
@job_offer&.public_send(method_name, *args) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment