Class: ActionDispatch::Routing::Mapper::Scope
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/routing/mapper.rb |
Constant Summary
-
OPTIONS =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2290[:path, :shallow_path, :as, :shallow_prefix, :module, :controller, :action, :path_names, :constraints, :shallow, :blocks, :defaults, :via, :format, :, :to]
-
RESOURCE_METHOD_SCOPES =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2295[:collection, :member, :new]
-
RESOURCE_SCOPES =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2294[:resource, :resources]
-
ROOT =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2374Scope.new({}, nil)
Class Method Summary
Instance Attribute Summary
- #nested? ⇒ Boolean readonly
- #null? ⇒ Boolean readonly
- #parent readonly
- #resource_method_scope? ⇒ Boolean readonly
- #resource_scope? ⇒ Boolean readonly
- #resources? ⇒ Boolean readonly
- #root? ⇒ Boolean readonly
- #scope_level readonly
::Enumerable
- Included
#many? | Returns |
Instance Method Summary
- #[](key)
- #action_name(name_prefix, prefix, collection_name, member_name)
- #each
- #frame
- #new(hash)
- #new_level(level)
- #options
::Enumerable
- Included
#compact_blank | Returns a new |
#exclude? | The negative of the |
#excluding | Returns a copy of the enumerable excluding the specified elements. |
#in_order_of | Returns a new |
#including | Returns a new array that includes the passed elements. |
#index_by | Convert an enumerable to a hash, using the block result as the key and the element as the value. |
#index_with | Convert an enumerable to a hash, using the element as the key and the block result as the value. |
#maximum | Calculates the maximum from the extracted elements. |
#minimum | Calculates the minimum from the extracted elements. |
#pick | Extract the given key from the first element in the enumerable. |
#pluck | Extract the given key from each element in the enumerable. |
#sole | Returns the sole item in the enumerable. |
#without | Alias for Enumerable#excluding. |
#as_json |
::ActiveSupport::EnumerableCoreExt::Constants
- Included
Constructor Details
.new(hash, parent = ROOT, scope_level = nil) ⇒ Scope
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2299
def initialize(hash, parent = ROOT, scope_level = nil) @parent = parent @hash = parent ? parent.frame.merge(hash) : hash @scope_level = scope_level end
Instance Attribute Details
#nested? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2305
def nested? scope_level == :nested end
#null? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2309
def null? @hash.nil? && @parent.nil? end
#parent (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2297
attr_reader :parent, :scope_level
#resource_method_scope? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2321
def resource_method_scope? RESOURCE_METHOD_SCOPES.include? scope_level end
#resource_scope? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2342
def resource_scope? RESOURCE_SCOPES.include? scope_level end
#resources? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2317
def resources? scope_level == :resources end
#root? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2313
def root? @parent == ROOT end
#scope_level (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2297
attr_reader :parent, :scope_level
Instance Method Details
#[](key)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2358
def [](key) frame[key] end
#action_name(name_prefix, prefix, collection_name, member_name)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2325
def action_name(name_prefix, prefix, collection_name, member_name) case scope_level when :nested [name_prefix, prefix] when :collection [prefix, name_prefix, collection_name] when :new [prefix, :new, name_prefix, member_name] when :member [prefix, name_prefix, member_name] when :root [name_prefix, collection_name, prefix] else [name_prefix, member_name, prefix] end end
#each
[ GitHub ]#frame
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2362
def frame; @hash; end
#new(hash)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2350
def new(hash) self.class.new hash, self, scope_level end
#new_level(level)
[ GitHub ]#options
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2346
def OPTIONS end