Module: Acfs::Resource::Locatable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Acfs::Resource
- Defined in:
- lib/acfs/resource/locatable.rb
Overview
Provide methods for generation URLs for resources.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#need_primary_key? ⇒ Boolean
private
Return true if resource needs a primary key (id) for singular actions.
-
#primary_key? ⇒ Boolean
private
Return true if resource has a primary key (id) set.
-
#url(opts = {}) ⇒ String
Return URL for this resource.
Instance Method Details
#need_primary_key? ⇒ Boolean
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.
Return true if resource needs a primary key (id) for singular actions.
122 123 124 |
# File 'lib/acfs/resource/locatable.rb', line 122 def need_primary_key? true end |
#primary_key? ⇒ Boolean
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.
Return true if resource has a primary key (id) set.
128 129 130 |
# File 'lib/acfs/resource/locatable.rb', line 128 def primary_key? respond_to?(:id) && !id.nil? end |
#url(opts = {}) ⇒ String
Return URL for this resource. Resource if will be appended as suffix if present.
112 113 114 115 116 117 118 |
# File 'lib/acfs/resource/locatable.rb', line 112 def url(opts = {}) return nil if need_primary_key? && !primary_key? self.class.service .location(self.class, opts.reverse_merge(action: :read)) .build(attributes).str end |