Module: RESTFramework::BaseControllerMixin::ClassMethods
- Defined in:
- lib/rest_framework/controller_mixins/base.rb
Instance Method Summary collapse
-
#get_actions_metadata ⇒ Object
Collect actions (including extra actions) metadata for this controller.
-
#get_member_actions_metadata ⇒ Object
Collect member actions (including extra member actions) metadata for this controller.
-
#get_options_metadata ⇒ Object
Get a hash of metadata to be rendered in the ‘OPTIONS` response.
Instance Method Details
#get_actions_metadata ⇒ Object
Collect actions (including extra actions) metadata for this controller.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rest_framework/controller_mixins/base.rb', line 16 def actions = {} # Start with builtin actions. RESTFramework::BUILTIN_ACTIONS.merge( RESTFramework::RRF_BUILTIN_ACTIONS, ).each do |action, methods| actions[action] = {path: "", methods: methods} if self.method_defined?(action) end # Add extra actions. if extra_actions = self.try(:extra_actions) actions.merge!(RESTFramework::Utils.parse_extra_actions(extra_actions)) end return actions end |
#get_member_actions_metadata ⇒ Object
Collect member actions (including extra member actions) metadata for this controller.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rest_framework/controller_mixins/base.rb', line 35 def actions = {} # Start with builtin actions. RESTFramework::BUILTIN_MEMBER_ACTIONS.each do |action, methods| actions[action] = {path: "", methods: methods} if self.method_defined?(action) end # Add extra actions. if extra_actions = self.try(:extra_member_actions) actions.merge!(RESTFramework::Utils.parse_extra_actions(extra_actions)) end return actions end |
#get_options_metadata ⇒ Object
Get a hash of metadata to be rendered in the ‘OPTIONS` response. Cache the result.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rest_framework/controller_mixins/base.rb', line 52 def return @_base_options_metadata ||= { name: self.&.name || self.controller_name.titleize, description: self.&.description, renders: [ "text/html", self.serialize_to_json ? "application/json" : nil, self.serialize_to_xml ? "application/xml" : nil, ].compact, actions: self., member_actions: self., }.compact end |