Module: InheritedResources::Helpers::Resources
- Defined in:
- lib/inherited_resources/helpers/resources.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collection_name ⇒ Object
- #instance_name ⇒ Object
- #parent_resource ⇒ Object
- #parent_resources ⇒ Object
- #resource ⇒ Object
- #resources ⇒ Object
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_name ⇒ Object
12 13 14 |
# File 'lib/inherited_resources/helpers/resources.rb', line 12 def collection_name resource.type.underscore.pluralize end |
#instance_name ⇒ Object
8 9 10 |
# File 'lib/inherited_resources/helpers/resources.rb', line 8 def instance_name resource.type.underscore.singularize end |
#parent_resource ⇒ Object
25 26 27 |
# File 'lib/inherited_resources/helpers/resources.rb', line 25 def parent_resource parent_resources.last end |
#parent_resources ⇒ Object
29 30 31 |
# File 'lib/inherited_resources/helpers/resources.rb', line 29 def parent_resources resources[0..-2] end |
#resource ⇒ Object
16 17 18 |
# File 'lib/inherited_resources/helpers/resources.rb', line 16 def resource member_action? ? super : build_resource end |
#resources ⇒ Object
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 |