Class: ActionDispatch::Routing::Mapper::Resources::Resource
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/routing/mapper.rb |
Class Method Summary
Instance Attribute Summary
-
#collection_scope
readonly
Alias for #path.
- #controller readonly
- #param readonly
- #path (also: #collection_scope, #member_scope, #nested_scope) readonly
- #shallow? ⇒ Boolean readonly
- #singleton? ⇒ Boolean readonly
Instance Method Summary
- #actions
- #available_actions
-
#collection_name
Checks for uncountable plurals, and appends “_index” if the plural and singular form are the same.
- #default_actions
-
#member_name
Alias for #singular.
- #member_scope (also: #shallow_scope) readonly
- #name
- #nested_param
- #nested_scope readonly
- #new_scope(new_path)
- #plural
- #resource_scope
-
#shallow_scope
Alias for #member_scope.
- #singular (also: #member_name)
Constructor Details
.new(entities, api_only, shallow, options = {}) ⇒ Resource
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1179
def initialize(entities, api_only, shallow, = {}) if [:param].to_s.include?(":") raise ArgumentError, ":param option can't contain colons" end @name = entities.to_s @path = ( [:path] || @name).to_s @controller = ( [:controller] || @name).to_s @as = [:as] @param = ( [:param] || :id).to_sym @options = @shallow = shallow @api_only = api_only @only = .delete :only @except = .delete :except end
Instance Attribute Details
#collection_scope (readonly)
Alias for #path.
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1244
alias :collection_scope :path
#controller (readonly)
[ GitHub ]#param (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1177
attr_reader :controller, :path, :param
#path (readonly) Also known as: #collection_scope, #member_scope, #nested_scope
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1177
attr_reader :controller, :path, :param
#shallow? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1264
def shallow? @shallow end
#singleton? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1268
def singleton?; false; end
Instance Method Details
#actions
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1204
def actions if @except available_actions - Array(@except).map(&:to_sym) else available_actions end end
#available_actions
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1212
def available_actions if @only Array(@only).map(&:to_sym) else default_actions end end
#collection_name
Checks for uncountable plurals, and appends “_index” if the plural and singular form are the same.
#default_actions
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1196
def default_actions if @api_only [:index, :create, :show, :update, :destroy] else [:index, :create, :new, :show, :update, :destroy, :edit] end end
#member_name
Alias for #singular.
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1232
alias :member_name :singular
#member_scope (readonly) Also known as: #shallow_scope
[ GitHub ]#name
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1220
def name @as || @name end
#nested_param
[ GitHub ]#nested_scope (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1260
def nested_scope "#{path}/:#{nested_param}" end
#new_scope(new_path)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1252
def new_scope(new_path) "#{path}/#{new_path}" end
#plural
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1224
def plural @plural ||= name.to_s end
#resource_scope
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1240
def resource_scope controller end
#shallow_scope
Alias for #member_scope.
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1250
alias :shallow_scope :member_scope
#singular Also known as: #member_name
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1228
def singular @singular ||= name.to_s.singularize end