Reputation: 1368
I have a feed reader written in Rails (the logic is bit complex as I am scraping some data) and I am trying to generalize the methods. Here is my current structure -
Class Gizmodo
def update
update logic
end
end
Class Wired
def update
update logic
end
end
Now I am thinking of structure like this
Class Story
def update(feed_name)
logic for feed - stored somewhere
end
end
I am thinking of storing the methods in table as string and then use class_eval(string) to generate the code. I believe this is ineffective. What are the other ways of storing code?
P.S -
Upvotes: 0
Views: 64
Reputation: 18988
Try creating a module inside the "lib" directory. All files in the lib directory are automatically loaded on server startup. Create a module, place your feed logic there, and include the module in the controllers that need it. That's how I do it.
Upvotes: 1