Reputation: 8402
I am using facebooker in one of my applications. I want to add some application specific methods to various classes in it? e.g.
In facebooker/lib/facebooker/models/user.rb
module Facebooker
class User
# I want to add my methods here. for e.g my_method
end
end
I can not directly put my_method
in the plugin itself since I also want to access my models from there. Not defining the methods in plugin code itself will also be helpful when I upgrade.
Upvotes: 0
Views: 78
Reputation: 2112
Somewhere in the file you wish to use my_method, type in, include, or require the following code:
module Facebooker
class User
def my_method
#whatever
end
end
end
Ruby will then add my_method to Facebooker's User class before you need to call it.
Upvotes: 1
Reputation: 468
try monkeypatching the facebooker plugin inside the model you are using it in, that way your edits only affect code inside the model you are wanting your edits to work in
Upvotes: 0