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, #available_actions, #name, #nested_param, #new_scope, #resource_scope, #shallow?

Constructor Details

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

Returns a new instance of SingletonResource.



1272
1273
1274
1275
1276
1277
# File 'lib/action_dispatch/routing/mapper.rb', line 1272

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



1279
1280
1281
1282
1283
1284
1285
# File 'lib/action_dispatch/routing/mapper.rb', line 1279

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

#pluralObject



1287
1288
1289
# File 'lib/action_dispatch/routing/mapper.rb', line 1287

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

#singleton?Boolean

Returns:

  • (Boolean)


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

def singleton?; true; end

#singularObject Also known as: member_name, collection_name



1291
1292
1293
# File 'lib/action_dispatch/routing/mapper.rb', line 1291

def singular
  @singular ||= name.to_s
end