Module: Iord::ResourceUrl
Instance Method Summary collapse
- #collection_url(options = {}) ⇒ Object
- #collection_url_defaults ⇒ Object
- #collection_url_method ⇒ Object
- #edit_resource_url(resource = nil) ⇒ Object
- #edit_resource_url? ⇒ Boolean
- #edit_resource_url_method ⇒ Object
- #form_resource_url ⇒ Object
- #has_collection? ⇒ Boolean
- #new_resource_url ⇒ Object
- #new_resource_url? ⇒ Boolean
- #new_resource_url_method ⇒ Object
- #resource_url(resource = nil) ⇒ Object
- #resource_url_method ⇒ Object
Instance Method Details
#collection_url(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/iord/resource_url.rb', line 49 def collection_url( = {}) if .present? if == true = collection_url_defaults else = collection_url_defaults.merge() end return self.public_send collection_url_method, else @collection_url ||= self.public_send collection_url_method end end |
#collection_url_defaults ⇒ Object
45 46 47 |
# File 'lib/iord/resource_url.rb', line 45 def collection_url_defaults @collection_url_defaults ||= Hash.new end |
#collection_url_method ⇒ Object
27 28 29 |
# File 'lib/iord/resource_url.rb', line 27 def collection_url_method @collection_url_method ||= (action_path.pluralize + '_url').to_sym end |
#edit_resource_url(resource = nil) ⇒ Object
78 79 80 81 82 |
# File 'lib/iord/resource_url.rb', line 78 def edit_resource_url(resource = nil) resource ||= @resource resource = nil unless has_collection? self.public_send(edit_resource_url_method, resource) end |
#edit_resource_url? ⇒ Boolean
75 76 77 |
# File 'lib/iord/resource_url.rb', line 75 def edit_resource_url? self.respond_to?(edit_resource_url_method) end |
#edit_resource_url_method ⇒ Object
72 73 74 |
# File 'lib/iord/resource_url.rb', line 72 def edit_resource_url_method @edit_resource_url_method ||= "edit_#{resource_url_method}".to_sym end |
#form_resource_url ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/iord/resource_url.rb', line 31 def form_resource_url if @resource.persisted? or not has_collection? resource_url else collection_url end end |
#has_collection? ⇒ Boolean
19 20 21 |
# File 'lib/iord/resource_url.rb', line 19 def has_collection? @has_collection ||= self.respond_to? collection_url_method end |
#new_resource_url ⇒ Object
68 69 70 |
# File 'lib/iord/resource_url.rb', line 68 def new_resource_url @new_resource_url ||= self.public_send(new_resource_url_method) end |
#new_resource_url? ⇒ Boolean
65 66 67 |
# File 'lib/iord/resource_url.rb', line 65 def new_resource_url? self.respond_to?(new_resource_url_method) end |
#new_resource_url_method ⇒ Object
62 63 64 |
# File 'lib/iord/resource_url.rb', line 62 def new_resource_url_method @new_resource_url_method ||= "new_#{resource_url_method}".to_sym end |
#resource_url(resource = nil) ⇒ Object
39 40 41 42 43 |
# File 'lib/iord/resource_url.rb', line 39 def resource_url(resource = nil) resource ||= @resource resource = nil unless has_collection? self.public_send resource_url_method.to_sym, resource end |
#resource_url_method ⇒ Object
23 24 25 |
# File 'lib/iord/resource_url.rb', line 23 def resource_url_method @resource_url_method ||= action_path.singularize + '_url' end |