Created
October 7, 2009 09:59
-
-
Save ledermann/203930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Liquid methods reflection for ActiveRecord | |
# Wanna know the defined liquid_methods for a given model? | |
# | |
# Example usage: | |
# | |
# class Person < ActiveRecord::Base | |
# liquid_methods :first_name, :last_name | |
# end | |
# | |
# Person.find(123).reflect_on_liquid_methods | |
# => ["first_name", "last_name"] | |
class ActiveRecord::Base | |
def reflect_on_liquid_methods | |
to_liquid.methods - Liquid::Drop.instance_methods | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment