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

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Resource

#controller, #param, #path

Class Method Summary collapse

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.



1429
1430
1431
1432
1433
1434
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1429

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

Class Method Details

.default_actions(api_only) ⇒ Object



1420
1421
1422
1423
1424
1425
1426
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1420

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

Instance Method Details

#default_actionsObject



1436
1437
1438
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1436

def default_actions
  self.class.default_actions(@api_only)
end

#pluralObject



1440
1441
1442
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1440

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

#singleton?Boolean

Returns:

  • (Boolean)


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

def singleton?; true; end

#singularObject Also known as: member_name, collection_name



1444
1445
1446
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 1444

def singular
  @singular ||= name.to_s
end