Class: URI::PlateID
- Inherits:
-
Generic
- Object
- Generic
- URI::PlateID
- Defined in:
- lib/uri/plate_id.rb
Constant Summary collapse
- MAPPING =
{ "Site" => { host: "Base", base_class: "Site" }, "Ngn::Site" => { host: "Base", base_class: "Site" }, "Org::Site" => { host: "Base", base_class: "Site" }, "Ngn::Attachment" => { host: "Base", base_class: "Attachment" }, "Ngn::AttachmentSetting" => { host: "Base", base_class: "AttachmentSetting" }, "Ngn::AttachmentFolder" => { host: "Base", base_class: "AttachmentFolder" }, "Ngn::Domain" => { host: "Base", base_class: "Domain" }, "Ngn::ClipboardItem" => { host: "Base", base_class: "ClipboardItem" }, "Ngn::VersionControl::Actions::Action" => { host: "Base", base_class: "VersionControl" }, "Ngn::Redirect" => { host: "Base", base_class: "Redirect" }, "Ngn::Content::Post" => { host: "Content", base_class: "Post" }, "Ngn::Content::Section" => { host: "Content", base_class: "Section" }, "Ngn::Content::Row" => { host: "Content", base_class: "Row" }, "Ngn::Content::Column" => { host: "Content", base_class: "Column" }, "Ngn::Content::Element" => { host: "Content", base_class: "Element" }, "Ngn::Content::ContentObject" => { host: "Content", base_class: "ContentObject" }, "Ngn::Content::SiteTranslation" => { host: "Content", base_class: "SiteTranslation" }, "Ngn::Content::AuthenticationObject" => { host: "Content", base_class: "AuthenticationObject" }, "Ngn::ContentModel::ContentField" => { host: "ContentModel", base_class: "ContentField" }, "Ngn::ContentModel::ContentFieldTab" => { host: "ContentModel", base_class: "ContentFieldGroup" }, "Ngn::ContentModel::PostType" => { host: "ContentModel", base_class: "PostType" }, "Ngn::ContentModel::SectionType" => { host: "ContentModel", base_class: "SectionType" }, "Ngn::ContentModel::ElementType" => { host: "ContentModel", base_class: "ElementType" }, "Ngn::ContentModel::ObjectTypeKind" => { host: "ContentModel", base_class: "ContentType" }, "Ngn::ContentModel::ObjectType" => { host: "ContentModel", base_class: "ObjectType" }, # TODO: legacy, to be replaced with typed kinds "Ngn::ContentModel::TrayType" => { host: "ContentModel", base_class: "TrayType" }, "Ngn::ContentModel::AuthenticationType" => { host: "ContentModel", base_class: "AuthenticationType" }, "Ngn::ContentModel::ContentFieldDefinition" => { host: "ContentModel", base_class: "ContentFieldDefinition" }, "Ngn::ContentModel::ContentFieldDefinitionGroup" => { host: "ContentModel", base_class: "ContentFieldDefinitionGroup" }, "Ngn::ContentModel::ContentFieldDefinitionGroupAssignment" => { host: "ContentModel", base_class: "ContentFieldDefinitionGroupAssignment" }, "Ngn::Theming::Theme" => { host: "Theming", base_class: "Theme" }, "Ngn::Theming::ThemeFile" => { host: "Theming", base_class: "ThemeFile" }, "Ngn::Theming::Prerender" => { host: "Theming", base_class: "Prerender" }, "Ngn::MultiContent::MultiSiteConnection" => { host: "MultiContent", base_class: "MultiSiteConnection" }, "Ngn::MultiContent::MultiContentConnection" => { host: "MultiContent", base_class: "MultiContentConnection" }, "Ngn::MultiContent::MultiContentRule" => { host: "MultiContent", base_class: "MultiContentRule" }, "Ngn::MultiContent::MultiContentRuleAssignment" => { host: "MultiContent", base_class: "MultiContentRuleAssignment" }, "Org::Auth::User" => { host: "Auth", base_class: "User" }, "Api::Integration" => { host: "Auth", base_class: "ApiIntegration" }, "Org::Company" => { host: "Organization", base_class: "Company" }, "Org::Partner" => { host: "Organization", base_class: "Partner" }, "Org::FormMessage" => { host: "Organization", base_class: "FormMessage" }, # Access control "AccessControl::Policy" => { host: "AccessControl", base_class: "Policy" }, "AccessControl::Role" => { host: "AccessControl", base_class: "Role" }, "AccessControl::Group" => { host: "AccessControl", base_class: "Group" } }
Instance Attribute Summary collapse
-
#base_class ⇒ Object
readonly
Returns the value of attribute base_class.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
-
.build(args) ⇒ Object
Create a new URI::PlateID from components with argument check.
-
.create(model) ⇒ Object
Shorthand to build a URI::PlateID from a model.
-
.parse(uri) ⇒ Object
Create a new URI::PlateID by parsing a plateid string with argument check.
Instance Method Summary collapse
-
#to_s ⇒ Object
Implement #to_s to avoid no implicit conversion of nil into string when path is nil.
Instance Attribute Details
#base_class ⇒ Object (readonly)
Returns the value of attribute base_class.
71 72 73 |
# File 'lib/uri/plate_id.rb', line 71 def base_class @base_class end |
#id ⇒ Object
Returns the value of attribute id.
71 72 73 |
# File 'lib/uri/plate_id.rb', line 71 def id @id end |
Class Method Details
.build(args) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/uri/plate_id.rb', line 103 def build(args) comps = Util.make_components_hash(self, args) return unless comps parts = MAPPING[comps[:model_name]].dup raise "There is no PlateID definition for this class: #{comps[:model_name]}" unless parts parts[:scheme] = comps[:scheme] parts[:id] = comps[:model_id] parts[:path] = "/#{parts[:base_class]}/#{CGI.escape(parts[:id].to_s)}" super(parts) end |
.create(model) ⇒ Object
87 88 89 90 |
# File 'lib/uri/plate_id.rb', line 87 def create(model) model = model.new if model.class == Class build(model_name: model.class.name, model_id: model.id) end |
.parse(uri) ⇒ Object
78 79 80 81 |
# File 'lib/uri/plate_id.rb', line 78 def parse(uri) generic_components = URI.split(uri) << nil << true # nil parser, true arg_check new(*generic_components) end |
Instance Method Details
#to_s ⇒ Object
Implement #to_s to avoid no implicit conversion of nil into string when path is nil
119 120 121 |
# File 'lib/uri/plate_id.rb', line 119 def to_s "plateid://#{host}/#{base_class}/#{id}" end |