Module: InheritedResources::Helpers::Resources

Defined in:
lib/inherited_resources/helpers/resources.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/inherited_resources/helpers/resources.rb', line 4

def self.included(base)
  base.send(:helper_method, public_instance_methods(false))
end

Instance Method Details

#collection_nameObject



12
13
14
# File 'lib/inherited_resources/helpers/resources.rb', line 12

def collection_name
  resource.type.underscore.pluralize
end

#instance_nameObject



8
9
10
# File 'lib/inherited_resources/helpers/resources.rb', line 8

def instance_name
  resource.type.underscore.singularize
end

#parent_resourceObject



25
26
27
# File 'lib/inherited_resources/helpers/resources.rb', line 25

def parent_resource
  parent_resources.last
end

#parent_resourcesObject



29
30
31
# File 'lib/inherited_resources/helpers/resources.rb', line 29

def parent_resources
  resources[0..-2]
end

#resourceObject



16
17
18
# File 'lib/inherited_resources/helpers/resources.rb', line 16

def resource
  member_action? ? super : build_resource
end

#resourcesObject



20
21
22
23
# File 'lib/inherited_resources/helpers/resources.rb', line 20

def resources
  @resources ||= with_chain(resource).tap { |r| r.unshift(route_prefix) if route_prefix }
  @resources.dup
end