Class: UU::OS::UESURI
- Inherits:
-
REST::DTO
- Object
- REST::DTO
- UU::OS::UESURI
- Defined in:
- uu_os_framework-0.10.6/lib/uu/os/uesuri.rb
Overview
UESURI - UES Uniform Resource Identifier (URI with ues:
scheme).
Defined Under Namespace
Classes: Parameter
Constant Summary
- NIL_URI =
Nil object for UESURI. Typical usage is in the uuAPI when it is needed to represent empty/nil value.
UESURI.new('ues:[-1]:[-1]')
Class Method Summary (collapse)
-
+ (UESURI) create(data)
Creates a new UESURI instance with attributes from
data
.
Instance Method Summary (collapse)
-
- (String) artifact_code
Artifact code.
-
- (String) artifact_id
Artifact ID.
-
- (String) fragment
Fragment.
-
- (UESURI) initialize(data = nil)
constructor
Creates new instance of UESURI.
-
- (String) object_code
Object code.
-
- (String) object_id
Object ID.
-
- (Array<UU::OS::UESURI::Parameter>) parameters
Use case parameters.
-
- (String) role_code
Role (authority) code.
-
- (String) role_id
Role (authority) ID.
-
- (String) schema
Schema.
-
- (String) territory_code
Territory code.
-
- (String) territory_id
Territory ID.
-
- (String) use_case_code
Use case code.
-
- (String) use_case_id
Use case ID.
Methods inherited from REST::DTO
Constructor Details
- (UESURI) initialize(data = nil)
Creates new instance of UESURI.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 19 def initialize(data = nil) if data.nil? return elsif (!data.kind_of?String) && (!data.kind_of?UESURI) raise ArgumentError.new("Parameter must be a String or an instance of UESURI, but was #{data.class}.") end remain = data.to_s if remain[/^".*"$/] # It is URI in JSON remain = remain[1..-2] end # get schema parts = split_one(remain, ':') if parts.size != 2 raise "UESURI (#{data}) does not define schema" end @schema = parts[0] remain = parts[1] # get role (authority) parts = split_one(remain, '@') if parts.size == 2 @role = Part.new(parts[0]) remain = parts[1] end # get fragment parts = split_one(remain, '#', true) if parts.size == 2 @fragment = UESURI.send(:url_decode, parts[1]) remain = parts[0] end # get usecase part including parameters parts = split_one(remain, '?', true) if parts.size == 2 # separate parameters tmp = split_one(parts[1], '&') if !tmp[0].empty? # use case exists @use_case = Part.new(tmp[0]) end if tmp[1] # parameters exists @parameters = [] split_all(tmp[1], '&').each do |param| @parameters << Parameter.new(param) end end remain = parts[0] end # get uri parts @parts = [] parts = split_one(remain, ':') while parts[0] do @parts << Part.new(parts[0]) parts = split_one(parts[1]?parts[1]:'', ':') end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class UU::OS::REST::DTO
Class Method Details
+ (UESURI) create(data)
Creates a new UESURI instance with attributes from data
.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 95 def self.create(data) unless minimal_uesuri_parts?(data) raise ArgumentError.new("The hash does not contain enough data to represent a minimal UESURI (ues:TER:ART): #{data}") end builder = UESURIBuilder.new builder.set_role_code(data[:role_code]) builder.set_role_id(data[:role_id]) if data[:territory_expr] builder.set_territory_code(data[:territory_expr]) else builder.set_territory_code(data[:territory_code]) builder.set_territory_id(data[:territory_id]) end if data[:artifact_expr] builder.set_artifact_code(data[:artifact_expr]) else builder.set_artifact_code(data[:artifact_code]) builder.set_artifact_id(data[:artifact_id]) end if data[:object_expr] builder.set_object_code(data[:object_expr]) else builder.set_object_code(data[:object_code]) builder.set_object_id(data[:object_id]) end builder.set_use_case_code(data[:use_case_code]) builder.set_use_case_id(data[:use_case_id]) if data[:parameters] unless data[:parameters].kind_of?(Hash) raise ArgumentError.new("Parameters must be represented as a Hash, not #{data[:parameters].class}") end data[:parameters].each do |k,v| builder.add_parameter(k, v) end end builder.set_fragment(data[:fragment]) builder.to_uesuri end |
Instance Method Details
- (String) artifact_code
Artifact code.
183 184 185 186 187 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 183 def artifact_code if @parts[1] @parts[1].code end end |
- (String) artifact_id
Artifact ID.
191 192 193 194 195 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 191 def artifact_id if @parts[1] @parts[1].id end end |
- (String) fragment
Fragment.
250 251 252 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 250 def fragment @fragment end |
- (String) object_code
Object code.
199 200 201 202 203 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 199 def object_code if @parts[2] @parts[2].code end end |
- (String) object_id
Object ID.
218 219 220 221 222 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 218 def object_id if @parts[2] @parts[2].id end end |
- (Array<UU::OS::UESURI::Parameter>) parameters
Use case parameters.
244 245 246 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 244 def parameters @parameters end |
- (String) role_code
Role (authority) code.
151 152 153 154 155 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 151 def role_code if @role @role.code end end |
- (String) role_id
Role (authority) ID.
159 160 161 162 163 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 159 def role_id if @role @role.id end end |
- (String) schema
Schema.
145 146 147 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 145 def schema @schema end |
- (String) territory_code
Territory code.
167 168 169 170 171 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 167 def territory_code if @parts[0] @parts[0].code end end |
- (String) territory_id
Territory ID.
175 176 177 178 179 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 175 def territory_id if @parts[0] @parts[0].id end end |
- (String) use_case_code
Use case code.
228 229 230 231 232 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 228 def use_case_code if @use_case @use_case.code end end |
- (String) use_case_id
Use case ID.
236 237 238 239 240 |
# File 'uu_os_framework-0.10.6/lib/uu/os/uesuri.rb', line 236 def use_case_id if @use_case @use_case.id end end |