Module: Acfs::Resource::Locatable::ClassMethods
- Defined in:
- lib/acfs/resource/locatable.rb
Instance Method Summary collapse
-
#location(opts = {}) ⇒ Location
Return a location object able to build the URL for this resource and given action.
- #location_default_path(action, path) ⇒ Object private
- #url(suffix = nil, opts = {}) ⇒ Object
Instance Method Details
#location(opts = {}) ⇒ Location
Return a location object able to build the URL for this resource and given action.
84 85 86 |
# File 'lib/acfs/resource/locatable.rb', line 84 def location(opts = {}) service.location(self, opts) end |
#location_default_path(action, path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 92 93 94 95 96 |
# File 'lib/acfs/resource/locatable.rb', line 89 def location_default_path(action, path) case action when :list, :create path when :read, :update, :delete "#{path}/:id" end end |
#url(suffix) ⇒ String #url(opts = {}) ⇒ String
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/acfs/resource/locatable.rb', line 43 def url(suffix = nil, opts = {}) if suffix.is_a? Hash opts = suffix suffix = nil end opts[:action] = :list if suffix url = location(opts).build(opts).str url += "/#{suffix}" if suffix.to_s.present? url end |