Class: Hanami::Routing::Resource Private

Inherits:
Object
  • Object
show all
Includes:
Utils::ClassAttribute
Defined in:
lib/hanami/routing/resource.rb,
lib/hanami/routing/resource/action.rb,
lib/hanami/routing/resource/nested.rb,
lib/hanami/routing/resource/options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Set of RESTful resource routes Implementation of Hanami::Router#resource

See Also:

Since:

  • 0.1.0

Direct Known Subclasses

Resources

Defined Under Namespace

Modules: DefaultMemberAction Classes: Action, CollectionAction, Create, Destroy, Edit, MemberAction, Nested, New, Options, Show, Update

Constant Summary collapse

NESTED_ROUTES_SEPARATOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

'/'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(router, name, options = {}, parent = nil, &blk) ⇒ Resource

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Resource.

Since:

  • 0.1.0


56
57
58
59
60
61
62
# File 'lib/hanami/routing/resource.rb', line 56

def initialize(router, name, options = {}, parent = nil, &blk)
  @router  = router
  @name    = name
  @parent  = parent
  @options = Options.new(self.class.actions, options.merge(name: @name))
  generate(&blk)
end

Instance Attribute Details

#parentObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0


52
53
54
# File 'lib/hanami/routing/resource.rb', line 52

def parent
  @parent
end

Instance Method Details

#resource(name, options = {}, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allow nested resource inside resource or resources

See Also:

Since:

  • 0.4.0


78
79
80
# File 'lib/hanami/routing/resource.rb', line 78

def resource(name, options = {}, &blk)
  _resource(Resource, name, options, &blk)
end

#resources(name, options = {}, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Allow nested resources inside resource or resources

See Also:

Since:

  • 0.4.0


69
70
71
# File 'lib/hanami/routing/resource.rb', line 69

def resources(name, options = {}, &blk)
  _resource(Resources, name, options, &blk)
end

#wildcard_param(route_param = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return separator

Since:

  • 0.4.0


86
87
88
# File 'lib/hanami/routing/resource.rb', line 86

def wildcard_param(route_param = nil)
  NESTED_ROUTES_SEPARATOR
end