Class: Ros::Urn

Inherits:
Struct
  • Object
show all
Defined in:
lib/ros/core.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id

Returns:

  • (Object)

    the current value of account_id



32
33
34
# File 'lib/ros/core.rb', line 32

def 
  @account_id
end

#partition_nameObject

Returns the value of attribute partition_name

Returns:

  • (Object)

    the current value of partition_name



32
33
34
# File 'lib/ros/core.rb', line 32

def partition_name
  @partition_name
end

#regionObject

Returns the value of attribute region

Returns:

  • (Object)

    the current value of region



32
33
34
# File 'lib/ros/core.rb', line 32

def region
  @region
end

#resourceObject

Returns the value of attribute resource

Returns:

  • (Object)

    the current value of resource



32
33
34
# File 'lib/ros/core.rb', line 32

def resource
  @resource
end

#service_nameObject

Returns the value of attribute service_name

Returns:

  • (Object)

    the current value of service_name



32
33
34
# File 'lib/ros/core.rb', line 32

def service_name
  @service_name
end

#txtObject

Returns the value of attribute txt

Returns:

  • (Object)

    the current value of txt



32
33
34
# File 'lib/ros/core.rb', line 32

def txt
  @txt
end

Class Method Details

.from_jwt(token) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/ros/core.rb', line 35

def self.from_jwt(token)
  jwt = Jwt.decode(token)
  return unless urn_string = jwt[0]['urn']
  urn_array = urn_string.split(':')
  new(*urn_array)
rescue JWT::DecodeError
end

Instance Method Details

#instanceObject



48
# File 'lib/ros/core.rb', line 48

def instance; model.find_by_urn(resource_id) end

#modelObject



47
# File 'lib/ros/core.rb', line 47

def model; model_name.constantize end

#model_nameObject



46
# File 'lib/ros/core.rb', line 46

def model_name; resource_type.classify end

#resource_idObject



44
# File 'lib/ros/core.rb', line 44

def resource_id; resource.split('/').last end

#resource_typeObject



43
# File 'lib/ros/core.rb', line 43

def resource_type; resource.split('/').first end

#to_sObject



33
# File 'lib/ros/core.rb', line 33

def to_s; to_a.join(':') end