Class: Ros::ApplicationRecord
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Ros::ApplicationRecord
- Includes:
- ApiBelongsTo
- Defined in:
- app/models/ros/application_record.rb
Overview
ALL models inherit from this class
Class Method Summary collapse
- .account_id ⇒ Object
- .current_tenant ⇒ Object
- .find_by_urn(value) ⇒ Object
-
.to_urn ⇒ Object
urn:partition:service:region:account_id:resource_type def self.to_urn; “#ApplicationRecord.urn_base:#current_tenant.try(:account_id):#namename.underscore” end.
-
.urn_base ⇒ Object
Universal Resource Name (URNs) and Service Namespaces urn:partition:service:region.
-
.urn_id ⇒ Object
NOTE: Override in model to provide a custom id.
Instance Method Summary collapse
- #current_tenant ⇒ Object
-
#to_urn ⇒ Object
urn:partition:service:region:account_id:resource_type/id.
Class Method Details
.account_id ⇒ Object
13 14 15 |
# File 'app/models/ros/application_record.rb', line 13 def self.account_id Apartment::Tenant.current.eql?('public') ? '' : Apartment::Tenant.current.remove('_') end |
.current_tenant ⇒ Object
17 |
# File 'app/models/ros/application_record.rb', line 17 def self.current_tenant; Tenant.find_by(schema_name: Apartment::Tenant.current) end |
.find_by_urn(value) ⇒ Object
23 |
# File 'app/models/ros/application_record.rb', line 23 def self.find_by_urn(value); find_by(urn_id => value) end |
.to_urn ⇒ Object
urn:partition:service:region:account_id:resource_type def self.to_urn; “#urn_base:#current_tenant.try(:account_id):#namename.underscore” end
11 |
# File 'app/models/ros/application_record.rb', line 11 def self.to_urn; "#{urn_base}:#{account_id}:#{name.underscore}" end |
.urn_base ⇒ Object
Universal Resource Name (URNs) and Service Namespaces urn:partition:service:region
21 |
# File 'app/models/ros/application_record.rb', line 21 def self.urn_base; "urn:#{Settings.service.partition_name}:#{Settings.service.name}:#{Settings.service.region}" end |
.urn_id ⇒ Object
NOTE: Override in model to provide a custom id
31 |
# File 'app/models/ros/application_record.rb', line 31 def self.urn_id; :id end |
Instance Method Details
#current_tenant ⇒ Object
28 |
# File 'app/models/ros/application_record.rb', line 28 def current_tenant; self.class.current_tenant end |
#to_urn ⇒ Object
urn:partition:service:region:account_id:resource_type/id
26 |
# File 'app/models/ros/application_record.rb', line 26 def to_urn; "#{self.class.to_urn}/#{send(self.class.urn_id)}" end |