Class: ActionDispatch::Routing::Mapper::Resources::SingletonResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/action_dispatch/routing/mapper.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Resource

#controller, #param, #path

Instance Method Summary collapse

Methods inherited from Resource

#actions, #name, #nested_param, #new_scope, #resource_scope, #shallow?

Constructor Details

#initialize(entities, api_only, shallow, options) ⇒ SingletonResource

Returns a new instance of SingletonResource.



1198
1199
1200
1201
1202
1203
# File 'lib/action_dispatch/routing/mapper.rb', line 1198

def initialize(entities, api_only, shallow, options)
  super
  @as         = nil
  @controller = (options[:controller] || plural).to_s
  @as         = options[:as]
end

Instance Method Details

#default_actionsObject



1205
1206
1207
1208
1209
1210
1211
# File 'lib/action_dispatch/routing/mapper.rb', line 1205

def default_actions
  if @api_only
    [:show, :create, :update, :destroy]
  else
    [:show, :create, :update, :destroy, :new, :edit]
  end
end

#pluralObject



1213
1214
1215
# File 'lib/action_dispatch/routing/mapper.rb', line 1213

def plural
  @plural ||= name.to_s.pluralize
end

#singleton?Boolean

Returns:

  • (Boolean)


1227
# File 'lib/action_dispatch/routing/mapper.rb', line 1227

def singleton?; true; end

#singularObject Also known as: member_name, collection_name



1217
1218
1219
# File 'lib/action_dispatch/routing/mapper.rb', line 1217

def singular
  @singular ||= name.to_s
end