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 they're.
- - (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
776 777 778 779 780 781 782 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 776 def initialize(entities, = {}) @name = entities.to_s @path = (.delete(:path) || @name).to_s @controller = (.delete(:controller) || @name).to_s @as = .delete(:as) @options = end |
Instance Attribute Details
- (Object) controller (readonly)
Returns the value of attribute controller
774 775 776 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 774 def controller @controller end |
- (Object) options (readonly)
Returns the value of attribute options
774 775 776 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 774 def @options end |
- (Object) path (readonly) Also known as: collection_scope
Returns the value of attribute path
774 775 776 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 774 def path @path end |
Instance Method Details
- (Object) actions
788 789 790 791 792 793 794 795 796 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 788 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 they're.
813 814 815 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 813 def collection_name singular == plural ? "#{plural}_index" : plural end |
- (Object) default_actions
784 785 786 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 784 def default_actions self.class::DEFAULT_ACTIONS end |
- (Object) member_scope
823 824 825 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 823 def member_scope "#{path}/:id" end |
- (Object) name
798 799 800 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 798 def name @as || @name end |
- (Object) nested_scope
831 832 833 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 831 def nested_scope "#{path}/:#{singular}_id" end |
- (Object) new_scope(new_path)
827 828 829 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 827 def new_scope(new_path) "#{path}/#{new_path}" end |
- (Object) plural
802 803 804 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 802 def plural @plural ||= name.to_s end |
- (Object) resource_scope
817 818 819 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 817 def resource_scope { :controller => controller } end |
- (Object) singular Also known as: member_name
806 807 808 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 806 def singular @singular ||= name.to_s.singularize end |