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 = NULL, scope_level = nil) ⇒ Scope

[ GitHub ]

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

def initialize(hash, parent = NULL, scope_level = nil)
  @hash = hash
  @parent = parent
  @scope_level = scope_level
end

Instance Attribute Details

#nested?Boolean (readonly)

[ GitHub ]

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

def nested?
  scope_level == :nested
end

#null?Boolean (readonly)

[ GitHub ]

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

def null?
  @hash.nil? && @parent.nil?
end

#parent (readonly)

[ GitHub ]

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

attr_reader :parent, :scope_level

#resource_method_scope?Boolean (readonly)

[ GitHub ]

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

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 2314

def resource_scope?
  RESOURCE_SCOPES.include? scope_level
end

#resources?Boolean (readonly)

[ GitHub ]

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

def resources?
  scope_level == :resources
end

#root?Boolean (readonly)

[ GitHub ]

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

def root?
  @parent.null?
end

#scope_level (readonly)

[ GitHub ]

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

attr_reader :parent, :scope_level

Instance Method Details

#[](key)

[ GitHub ]

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

def [](key)
  scope = find { |node| node.frame.key? key }
  scope && scope.frame[key]
end

#action_name(name_prefix, prefix, collection_name, member_name)

[ GitHub ]

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

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 2337

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

#frame

[ GitHub ]

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

def frame; @hash; end

#new(hash)

[ GitHub ]

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

def new(hash)
  self.class.new hash, self, scope_level
end

#new_level(level)

[ GitHub ]

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

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

#options

[ GitHub ]

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

def options
  OPTIONS
end