123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Routing::Mapper::Scope

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/routing/mapper.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

::Enumerable - Included

#many?

Returns true if the enumerable has more than 1 element.

Instance Method Summary

::Enumerable - Included

#compact_blank

Returns a new ::Array without the blank items.

#exclude?

The negative of the Enumerable#include?.

#excluding

Returns a copy of the enumerable excluding the specified elements.

#in_order_of

Returns a new ::Array where the order has been set to that provided in the series, based on the key of the objects in the original enumerable.

#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
#as_json

::ActiveSupport::EnumerableCoreExt::Constants - Included

Constructor Details

.new(hash, parent = ROOT, scope_level = nil) ⇒ Scope

[ GitHub ]

  
# 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 ]

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

def each
  node = self
  until node.equal? ROOT
    yield node
    node = node.parent
  end
end

#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 ]

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

def new_level(level)
  self.class.new(frame, self, level)
end

#options

[ GitHub ]

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

def options
  OPTIONS
end