Class: Datadog::Core::Remote::Configuration::Path
- Inherits:
-
Object
- Object
- Datadog::Core::Remote::Configuration::Path
- Defined in:
- lib/datadog/core/remote/configuration/path.rb
Overview
Path stores path information
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- RE =
%r{ ^ (?<source> datadog/(?<org_id>\d+) | employee ) / (?<product>[^/]+) / (?<config_id>[^/]+) / (?<name>[^/]+) $ }mx.freeze
Instance Attribute Summary collapse
-
#config_id ⇒ Object
readonly
Returns the value of attribute config_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#org_id ⇒ Object
readonly
Returns the value of attribute org_id.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(source:, product:, config_id:, name:, org_id: nil) ⇒ Path
constructor
A new instance of Path.
- #to_s ⇒ Object
Constructor Details
#initialize(source:, product:, config_id:, name:, org_id: nil) ⇒ Path
Returns a new instance of Path.
55 56 57 58 59 60 61 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 55 def initialize(source:, product:, config_id:, name:, org_id: nil) @source = source @org_id = org_id @product = product @config_id = config_id @name = name end |
Instance Attribute Details
#config_id ⇒ Object (readonly)
Returns the value of attribute config_id.
53 54 55 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 53 def config_id @config_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
53 54 55 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 53 def name @name end |
#org_id ⇒ Object (readonly)
Returns the value of attribute org_id.
53 54 55 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 53 def org_id @org_id end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
53 54 55 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 53 def product @product end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
53 54 55 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 53 def source @source end |
Class Method Details
.parse(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 28 def parse(path) m = RE.match(path) raise ParseError, "could not parse: #{path.inspect}" if m.nil? org_id = m['org_id'] ? m['org_id'].to_i : nil source = m['source'] raise ParseError, 'missing source value' unless source source = source.delete("/#{org_id}") if org_id product = m['product'] raise ParseError, 'missing product value' unless product config_id = m['config_id'] raise ParseError, 'missing config_id value' unless config_id name = m['name'] raise ParseError, 'missing name value' unless name new(source: source, org_id: org_id, product: product, config_id: config_id, name: name) end |
Instance Method Details
#==(other) ⇒ Object
73 74 75 76 77 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 73 def ==(other) return false unless other.is_a?(Path) to_s == other.to_s end |
#eql?(other) ⇒ Boolean
83 84 85 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 83 def eql?(other) hash == other.hash end |
#hash ⇒ Object
79 80 81 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 79 def hash to_s.hash end |
#to_s ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/datadog/core/remote/configuration/path.rb', line 65 def to_s if org_id "#{source}/#{org_id}/#{product}/#{config_id}/#{name}" else "#{source}/#{product}/#{config_id}/#{name}" end end |