mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Allow us to extend serializers easily in a plugin
This commit is contained in:
parent
645a22fdd5
commit
4748b21c56
1 changed files with 7 additions and 0 deletions
|
@ -37,6 +37,13 @@ class Plugin::Instance
|
|||
metadata.name
|
||||
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
|
||||
def generate_automatic_assets!
|
||||
paths = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue