Skip to content

Instantly share code, notes, and snippets.

@gaetanm
Created April 27, 2016 13:10
Show Gist options
  • Save gaetanm/ec49a7785d8471241796c96b3491e0c4 to your computer and use it in GitHub Desktop.
Save gaetanm/ec49a7785d8471241796c96b3491e0c4 to your computer and use it in GitHub Desktop.
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