Class: ActionController::Resources::Resource
- Defined in:
- lib/action_controller/resources.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#collection_methods ⇒ Object
readonly
Returns the value of attribute collection_methods.
-
#member_methods ⇒ Object
readonly
Returns the value of attribute member_methods.
-
#name_prefix ⇒ Object
readonly
Returns the value of attribute name_prefix.
-
#new_methods ⇒ Object
readonly
Returns the value of attribute new_methods.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path_prefix ⇒ Object
readonly
Returns the value of attribute path_prefix.
-
#plural ⇒ Object
readonly
Returns the value of attribute plural.
-
#singular ⇒ Object
readonly
Returns the value of attribute singular.
Instance Method Summary collapse
- #action_separator ⇒ Object
- #conditions ⇒ Object
- #controller ⇒ Object
-
#initialize(entities, options) ⇒ Resource
constructor
A new instance of Resource.
- #member_path ⇒ Object
- #nesting_name_prefix ⇒ Object
- #nesting_path_prefix ⇒ Object
- #new_path ⇒ Object
- #path ⇒ Object
- #requirements(with_id = false) ⇒ Object
- #uncountable? ⇒ Boolean
Constructor Details
#initialize(entities, options) ⇒ Resource
Returns a new instance of Resource.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/action_controller/resources.rb', line 51 def initialize(entities, ) @plural ||= entities @singular ||= [:singular] || plural.to_s.singularize @options = arrange_actions add_default_actions set_prefixes end |
Instance Attribute Details
#collection_methods ⇒ Object (readonly)
Returns the value of attribute collection_methods.
46 47 48 |
# File 'lib/action_controller/resources.rb', line 46 def collection_methods @collection_methods end |
#member_methods ⇒ Object (readonly)
Returns the value of attribute member_methods.
46 47 48 |
# File 'lib/action_controller/resources.rb', line 46 def member_methods @member_methods end |
#name_prefix ⇒ Object (readonly)
Returns the value of attribute name_prefix.
47 48 49 |
# File 'lib/action_controller/resources.rb', line 47 def name_prefix @name_prefix end |
#new_methods ⇒ Object (readonly)
Returns the value of attribute new_methods.
46 47 48 |
# File 'lib/action_controller/resources.rb', line 46 def new_methods @new_methods end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
49 50 51 |
# File 'lib/action_controller/resources.rb', line 49 def @options end |
#path_prefix ⇒ Object (readonly)
Returns the value of attribute path_prefix.
47 48 49 |
# File 'lib/action_controller/resources.rb', line 47 def path_prefix @path_prefix end |
#plural ⇒ Object (readonly)
Returns the value of attribute plural.
48 49 50 |
# File 'lib/action_controller/resources.rb', line 48 def plural @plural end |
#singular ⇒ Object (readonly)
Returns the value of attribute singular.
48 49 50 |
# File 'lib/action_controller/resources.rb', line 48 def singular @singular end |
Instance Method Details
#action_separator ⇒ Object
97 98 99 |
# File 'lib/action_controller/resources.rb', line 97 def action_separator @action_separator ||= Base.resource_action_separator end |
#conditions ⇒ Object
73 74 75 |
# File 'lib/action_controller/resources.rb', line 73 def conditions @conditions = @options[:conditions] || {} end |
#controller ⇒ Object
62 63 64 |
# File 'lib/action_controller/resources.rb', line 62 def controller @controller ||= "#{[:namespace]}#{([:controller] || plural).to_s}" end |
#member_path ⇒ Object
85 86 87 |
# File 'lib/action_controller/resources.rb', line 85 def member_path @member_path ||= "#{path}/:id" end |
#nesting_name_prefix ⇒ Object
93 94 95 |
# File 'lib/action_controller/resources.rb', line 93 def nesting_name_prefix "#{name_prefix}#{singular}_" end |
#nesting_path_prefix ⇒ Object
89 90 91 |
# File 'lib/action_controller/resources.rb', line 89 def nesting_path_prefix @nesting_path_prefix ||= "#{path}/:#{singular}_id" end |
#new_path ⇒ Object
81 82 83 |
# File 'lib/action_controller/resources.rb', line 81 def new_path @new_path ||= "#{path}/new" end |
#path ⇒ Object
77 78 79 |
# File 'lib/action_controller/resources.rb', line 77 def path @path ||= "#{path_prefix}/#{plural}" end |
#requirements(with_id = false) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/action_controller/resources.rb', line 66 def requirements(with_id = false) @requirements ||= @options[:requirements] || {} @id_requirement ||= { :id => @requirements.delete(:id) || /[^#{Routing::SEPARATORS.join}]+/ } with_id ? @requirements.merge(@id_requirement) : @requirements end |
#uncountable? ⇒ Boolean
101 102 103 |
# File 'lib/action_controller/resources.rb', line 101 def uncountable? @singular.to_s == @plural.to_s end |