Allow us to extend serializers easily in a plugin

This commit is contained in:
Robin Ward 2015-01-12 10:52:55 -05:00
parent 645a22fdd5
commit 4748b21c56
1 changed files with 7 additions and 0 deletions

View File

@ -37,6 +37,13 @@ class Plugin::Instance
metadata.name metadata.name
end end
def add_to_serializer(serializer, attr, &block)
klass = "#{serializer.to_s.classify}Serializer".constantize
klass.attributes(attr)
klass.send(:define_method, attr, &block)
end
# will make sure all the assets this plugin needs are registered # will make sure all the assets this plugin needs are registered
def generate_automatic_assets! def generate_automatic_assets!
paths = [] paths = []