Commit cbc96f12e46c887d9bddf6a0ab574af6cf98a585
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'noosfero_grape_api' into rails3_api
Conflicts: Rakefile
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
lib/api/api.rb
@@ -19,5 +19,15 @@ module API | @@ -19,5 +19,15 @@ module API | ||
19 | mount V1::Categories | 19 | mount V1::Categories |
20 | mount Session | 20 | mount Session |
21 | 21 | ||
22 | + # hook point which allow plugins to add Grape::API extensions to API::API | ||
23 | + #finds for plugins which has api mount points classes defined (the class should extends Grape::API) | ||
24 | + @plugins = Noosfero::Plugin.all.map { |p| p.constantize } | ||
25 | + @plugins.each do |klass| | ||
26 | + if klass.public_methods.include? 'api_mount_points' | ||
27 | + klass.api_mount_points.each do |mount_class| | ||
28 | + mount mount_class if mount_class && ( mount_class < Grape::API ) | ||
29 | + end | ||
30 | + end | ||
31 | + end | ||
22 | end | 32 | end |
23 | end | 33 | end |
lib/noosfero/plugin.rb
@@ -149,6 +149,10 @@ class Noosfero::Plugin | @@ -149,6 +149,10 @@ class Noosfero::Plugin | ||
149 | def has_admin_url? | 149 | def has_admin_url? |
150 | File.exists?(File.join(root_path, 'controllers', "#{name.underscore}_admin_controller.rb")) | 150 | File.exists?(File.join(root_path, 'controllers', "#{name.underscore}_admin_controller.rb")) |
151 | end | 151 | end |
152 | + | ||
153 | + # -> define grape class used to map resource api provided by the plugin | ||
154 | + def api_mount_points | ||
155 | + end | ||
152 | end | 156 | end |
153 | 157 | ||
154 | def expanded_template(file_path, locals = {}) | 158 | def expanded_template(file_path, locals = {}) |