Class: ActionDispatch::Routing::Mapper::Resources::Resource
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper::Resources::Resource
- Defined in:
- actionpack/lib/action_dispatch/routing/mapper.rb
Overview
:nodoc:
Constant Summary
- DEFAULT_ACTIONS =
[:index, :create, :new, :show, :update, :destroy, :edit]
Instance Attribute Summary (collapse)
-
- (Object) controller
readonly
Returns the value of attribute controller.
-
- (Object) options
readonly
Returns the value of attribute options.
-
- (Object) path
(also: #collection_scope)
readonly
Returns the value of attribute path.
Instance Method Summary (collapse)
- - (Object) actions
-
- (Object) collection_name
Checks for uncountable plurals, and appends "_index" if the plural and singular form are the same.
- - (Object) default_actions
-
- (Resource) initialize(entities, options = {})
constructor
A new instance of Resource.
- - (Object) member_scope
- - (Object) name
- - (Object) nested_scope
- - (Object) new_scope(new_path)
- - (Object) plural
- - (Object) resource_scope
- - (Object) singular (also: #member_name)
Constructor Details
- (Resource) initialize(entities, options = {})
A new instance of Resource
880 881 882 883 884 885 886 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 880 def initialize(entities, = {}) @name = entities.to_s @path = ([:path] || @name).to_s @controller = ([:controller] || @name).to_s @as = [:as] @options = end |
Instance Attribute Details
- (Object) controller (readonly)
Returns the value of attribute controller
878 879 880 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 878 def controller @controller end |
- (Object) options (readonly)
Returns the value of attribute options
878 879 880 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 878 def @options end |
- (Object) path (readonly) Also known as: collection_scope
Returns the value of attribute path
878 879 880 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 878 def path @path end |
Instance Method Details
- (Object) actions
892 893 894 895 896 897 898 899 900 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 892 def actions if only = @options[:only] Array(only).map(&:to_sym) elsif except = @options[:except] default_actions - Array(except).map(&:to_sym) else default_actions end end |
- (Object) collection_name
Checks for uncountable plurals, and appends "_index" if the plural and singular form are the same.
918 919 920 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 918 def collection_name singular == plural ? "#{plural}_index" : plural end |
- (Object) default_actions
888 889 890 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 888 def default_actions self.class::DEFAULT_ACTIONS end |
- (Object) member_scope
928 929 930 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 928 def member_scope "#{path}/:id" end |
- (Object) name
902 903 904 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 902 def name @as || @name end |
- (Object) nested_scope
936 937 938 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 936 def nested_scope "#{path}/:#{singular}_id" end |
- (Object) new_scope(new_path)
932 933 934 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 932 def new_scope(new_path) "#{path}/#{new_path}" end |
- (Object) plural
906 907 908 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 906 def plural @plural ||= name.to_s end |
- (Object) resource_scope
922 923 924 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 922 def resource_scope { :controller => controller } end |
- (Object) singular Also known as: member_name
910 911 912 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 910 def singular @singular ||= name.to_s.singularize end |