Class: Ace::Support::Config::Models::CascadePath
- Inherits:
-
Object
- Object
- Ace::Support::Config::Models::CascadePath
- Defined in:
- lib/ace/support/config/models/cascade_path.rb
Overview
Represents a configuration cascade path
Instance Attribute Summary collapse
-
#exists ⇒ Object
readonly
Returns the value of attribute exists.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare paths by priority.
- #==(other) ⇒ Object (also: #eql?)
-
#absolute? ⇒ Boolean
Check if path is absolute.
- #hash ⇒ Object
-
#initialize(path:, priority: 100, exists: false, type: :local) ⇒ CascadePath
constructor
Initialize cascade path.
- #inspect ⇒ Object
-
#overrides?(other) ⇒ Boolean
Check if this path should override another.
-
#pathname ⇒ Pathname
Get path as Pathname.
-
#relative? ⇒ Boolean
Check if path is relative.
-
#to_s ⇒ String
Convert to string.
Constructor Details
#initialize(path:, priority: 100, exists: false, type: :local) ⇒ CascadePath
Initialize cascade path
16 17 18 19 20 21 22 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 16 def initialize(path:, priority: 100, exists: false, type: :local) @path = path.to_s.freeze @priority = priority @exists = exists @type = type freeze end |
Instance Attribute Details
#exists ⇒ Object (readonly)
Returns the value of attribute exists.
9 10 11 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 9 def exists @exists end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 9 def path @path end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
9 10 11 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 9 def priority @priority end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 9 def type @type end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare paths by priority
27 28 29 30 31 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 27 def <=>(other) return nil unless other.is_a?(CascadePath) priority <=> other.priority end |
#==(other) ⇒ Object Also known as: eql?
67 68 69 70 71 72 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 67 def ==(other) other.is_a?(self.class) && other.path == path && other.priority == priority && other.type == type end |
#absolute? ⇒ Boolean
Check if path is absolute
57 58 59 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 57 def absolute? pathname.absolute? end |
#hash ⇒ Object
74 75 76 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 74 def hash [path, priority, type].hash end |
#inspect ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 80 def inspect attrs = [ "path=#{path.inspect}", "type=#{type}", "priority=#{priority}", exists ? "exists" : "missing" ].join(" ") "#<#{self.class.name} #{attrs}>" end |
#overrides?(other) ⇒ Boolean
Check if this path should override another
36 37 38 39 40 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 36 def overrides?(other) return false unless other.is_a?(CascadePath) priority < other.priority end |
#pathname ⇒ Pathname
Get path as Pathname
50 51 52 53 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 50 def pathname require "pathname" Pathname.new(path) end |
#relative? ⇒ Boolean
Check if path is relative
63 64 65 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 63 def relative? !absolute? end |
#to_s ⇒ String
Convert to string
44 45 46 |
# File 'lib/ace/support/config/models/cascade_path.rb', line 44 def to_s path end |