Skip to content

Instantly share code, notes, and snippets.

@astagi
Last active September 27, 2018 12:50
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 astagi/cd4812cecf0c2f2d1b53d9b52fdf0f92 to your computer and use it in GitHub Desktop.
Save astagi/cd4812cecf0c2f2d1b53d9b52fdf0f92 to your computer and use it in GitHub Desktop.
Dynamic generation
module Ansa
# ....
private
def self.generate_get_news(category, url)
define_singleton_method("get_#{category}_news") do
get_news_by_url(url)
end
end
public
LINKS.each do |category, url|
generate_get_news category, url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment