I want to create a gem which adds some functionality to my models. How to define a custom keyword for a Mongoid model? E.g.:
class Book
include Mongoid::Document
has_my_awesome_functionality
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have a gem called
foobaryou can put the following into your gem’s initialiser, or in a separate file (usually calledrailtie.rb[, just make sure it’s being loaded]):and your extension can look like this: