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.
125 126 127 |
# File 'lib/acfs/resource/locatable.rb', line 125 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.
131 132 133 |
# File 'lib/acfs/resource/locatable.rb', line 131 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.
115 116 117 118 119 120 121 |
# File 'lib/acfs/resource/locatable.rb', line 115 def url(**opts) return nil if need_primary_key? && !primary_key? self.class.service .location(self.class, **opts, action: :read) .build(attributes).str end |